🧪
Testing25M+/wkMIT

jest

Jest is a delightful JavaScript testing framework with a focus on simplicity, created by Facebook. It works out of the box for most JavaScript projects with zer

Installation

npm
npm install -D jest
yarn
yarn add -D jest
pnpm
pnpm add -D jest

Import

ESM
// jest tests use globals: describe, it, expect

Quick Example

usage
describe('sum', () => {
  it('adds 1 + 2 to equal 3', () => {
    expect(1 + 2).toBe(3);
  });

  it('returns negative for negative input', () => {
    expect(-1 + -2).toBe(-3);
  });
});

About jest

Jest is a delightful JavaScript testing framework with a focus on simplicity, created by Facebook. It works out of the box for most JavaScript projects with zero configuration, supporting test discovery, assertion matchers, mocking, code coverage, and snapshot testing. Jest runs tests in parallel using worker processes for speed, isolates each test file in its own environment to prevent state leakage, and includes a powerful mocking system that can mock functions, modules, timers, and entire libraries automatically. The framework provides built-in code coverage reporting using Istanbul, watch mode that re-runs only tests affected by changed files, and snapshot testing for capturing serialized output of React components or any data structure. Jest supports TypeScript through ts-jest or @swc/jest, async/await testing, custom matchers, and setup/teardown hooks at both the test and suite level. The expect assertion library offers rich matchers including toMatchObject, toThrow, toHaveBeenCalledWith, and asymmetric matchers for partial matching. Jest remains the most widely used JavaScript testing framework, particularly dominant in React projects.

Quick Facts

Packagejest
CategoryTesting
Weekly Downloads25M+
LicenseMIT
Installnpm install -D jest

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.