Jest

30.3.0 · active · verified Sat Apr 18

Jest is a delightful JavaScript testing framework designed to ensure the correctness of any JavaScript codebase. As of version 30.3.0, it offers powerful features like snapshot testing, isolated environments, and a comprehensive assertion library. While major releases historically had longer intervals (v30 after three years), the project aims for more frequent major updates, alongside regular minor and patch releases.

Common errors

Warnings

Install

Imports

Quickstart

This example shows a simple TypeScript function and its corresponding test using Jest's `describe` and `it` blocks with `expect` assertions.

// sum.ts
export function sum(a: number, b: number): number {
  return a + b;
}

// sum.test.ts
import { sum } from './sum';

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

// To run: `npx jest sum.test.ts`

view raw JSON →