Jest is a JavaScript testing framework by Meta that focuses on simplicity. It includes a test runner, assertion library, mocking system, and code coverage — everything needed for unit and integration testing in one package. It's the most popular JS testing framework.

How Jest Works

Jest runs tests with zero configuration: write a .test.js file, run npx jest. It auto-discovers tests, runs them in parallel, and reports results. Mocking is built in — jest.fn(), jest.mock('./module'). Snapshot testing catches unexpected UI changes.

Key Concepts

  • Zero Config — Jest works out of the box — auto-discovers tests, supports TypeScript with ts-jest, and runs in parallel
  • Mocking — Built-in mock functions, module mocking, and timer mocking — no extra libraries needed

Frequently Asked Questions

Jest vs Vitest?

Vitest is faster (native ESM, Vite integration) and has a compatible API. For Vite-based projects, use Vitest. For existing Jest setups or non-Vite projects, Jest is fine.