Socket
Socket
Sign inDemoInstall

jest-cli

Package Overview
Dependencies
98
Maintainers
1
Versions
389
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-cli

Painless JavaScript Unit Testing


Version published
Weekly downloads
22M
decreased by-2.78%
Maintainers
1
Created
Weekly downloads
 

Package description

What is jest-cli?

The jest-cli npm package is the command line interface for Jest, a popular JavaScript testing framework. It allows developers to run tests, configure Jest options, and interact with Jest directly from the command line. Jest is widely used for testing React applications, but it can also be used for testing other JavaScript code.

What are jest-cli's main functionalities?

Running Tests

Run all tests in a project. This is the most basic and commonly used command to start the Jest test runner.

jest

Running Tests in Watch Mode

Run Jest in watch mode. This command will re-run tests when files change, which is useful during development.

jest --watch

Running Specific Tests

Run tests in a specific file or files matching a pattern. This allows for more targeted testing.

jest testFileName

Configuring Jest

Specify a configuration file for Jest. This allows developers to customize how Jest behaves, including setting up test environments, mock implementations, and more.

jest --config=jest.config.js

Coverage Reporting

Generate a test coverage report. This helps developers understand which parts of their codebase are covered by tests.

jest --coverage

Other packages similar to jest-cli

Readme

Source

Jest

Painless JavaScript Unit Testing

  • Familiar Approach: Built on top of Jasmine test framework, a familiar BDD testing environment

  • Mock by Default: Automatically mocks CommonJS modules returned by require(), making most existing code testable

  • Short Feedback Loop: Tests run in parallel and DOM apis are mocked so you can run tests on the command line

Getting Started

Check out the Getting Started tutorial for more in-depth details.

API

<generated_api_start />

The jest object
Mock functions
Config options
Globally injected variables
  • jest
  • require(module)
  • require.requireActual(module)
  • describe(name, fn)
  • beforeEach(fn)
  • afterEach(fn)
  • it(name, fn)
  • it.only(name, fn) executes only this test. Useful when investigating a failure
  • pit(name, fn) helper for promises
expect(value)
  • .not inverse the next comparison
  • .toThrow(?message)
  • .toBe(value) comparison using ===
  • .toEqual(value) deep comparison. Use jasmine.any(type) to be softer
  • .toBeFalsy()
  • .toBeTruthy()
  • .toBeNull()
  • .toBeUndefined()
  • .toBeDefined()
  • .toMatch(regexp)
  • .toContain(string)
  • .toBeCloseTo(number, delta)
  • .toBeGreaterThan(number)
  • .toBeLessThan(number)
  • .toBeCalled()
  • .toBeCalledWith(arg, um, ents)
  • .lastCalledWith(arg, um, ents)

<generated_api_end />

FAQs

Last updated on 13 May 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc