Jest vs Vitest

Jest: Existing JavaScript projects already invested in the Jest ecosystem.; Vitest: Unit and integration tests in any modern TypeScript or Vite project.

FieldJestVitest
PricingOpen sourceOpen source
Open sourceYesYes
Self-hostableYesYes
EcosystemJavaScript / TypeScriptJavaScript / TypeScript
LicenseMITMIT
CategoryTestingTesting

Choose Vitest over Jest when

Choose it when tests should reuse your Vite plugins and configuration.

Vitest reads the project's Vite configuration by default, so a project can run tests with the same configured plugins it uses for its build. Teams that need a separate set of test settings can provide a dedicated Vitest configuration file (configuration).

SourceChecked 29 November 2026

Choose Jest over Vitest when

Choose it when the existing suite relies on Jest configuration for separate test projects or coverage thresholds.

Jest supports running multiple projects from one configuration and lets them carry their own settings, such as test matching. Its configuration also describes global and path-specific coverage thresholds, which can fail the test run when unmet (configuration).

SourceChecked 29 November 2026

Jest

A widely used JavaScript testing framework with built-in mocking, snapshots and coverage.

Choose Jest if

Existing JavaScript projects already invested in the Jest ecosystem.

Why it’s here

Jest runs JavaScript tests and supplies the pieces needed to assert results and replace dependencies. A mock created with jest.fn() records its calls and their results, and can return different values on successive calls (mock functions). Jest can also serialize a value and compare it with a snapshot checked into the repository (snapshot testing).

Pick it when

  • You want to check how one module uses another. The guide shows jest.mock() replacing a module and mockResolvedValue() controlling the result of an asynchronous dependency. You can exercise the caller against a specific response without calling the real dependency (mock functions).
  • Your suite splits server and browser-like tests. Jest uses a Node.js environment by default and also supports a jsdom environment. A file can select its own environment with an @jest-environment docblock (test environments).
  • You want changes to serialized output to show up in code review. Commit snapshots alongside their tests, give them descriptive names, and review the diff before updating them (snapshot testing).
  • You need the test run to enforce coverage for particular files or directories. coverageThreshold accepts global limits and limits for paths or globs, and Jest fails when the configured threshold is missed (configuration).

Skip it when

  • Native ESM support must be stable. Jest still documents it as experimental and directs users to run Node with --experimental-vm-modules (ESM guide).
  • You need screenshots to catch rendering changes. Jest's snapshot guide distinguishes serialized values from visual regression tests, which compare screenshots (snapshot FAQ).

Current state

Jest 30.5.2 was released on 2026-09-18 (release notes). The licence is MIT (repository licence).

Setup

Run npm install --save-dev jest. Add "test": "jest" to your package scripts, write a .test.js file, and run npm test (getting started).

Watch out for

Static ESM imports run before the rest of the file. When replacing an ES module, the ESM guide uses jest.unstable_mockModule() followed by a dynamic import, so register the mock before loading the module (ESM mocking). A failing snapshot calls for inspecting the difference first. Use --updateSnapshot when it reflects a deliberate change, or use interactive mode to review failing snapshots individually (updating snapshots).

Jest on GitHub

Vitest

A fast, Vite-native test runner with a Jest-compatible API, first-class TypeScript and ESM support.

Choose Vitest if

Unit and integration tests in any modern TypeScript or Vite project.

Why it’s here

Vitest runs tests with Vite. It reads the project's Vite configuration by default, so tests can use its configured plugins. A separate Vitest configuration is available when tests need their own settings (getting started). Use the watch workflow while editing and vitest run for a single run (getting started).

Pick it when

  • Your application already builds with Vite and you want tests to use the same plugins. Start with the shared configuration and add test-specific settings as needed (configuration).
  • You need to test browser behaviour directly. Browser Mode runs tests inside a browser and supports providers such as Playwright for headless runs (Browser Mode).
  • You want to substitute a dependency at the module boundary. Vitest transforms files that use vi.mock() so it can register a mock before the import is evaluated (module mocking).

Skip it when

  • Your test runner must stay on Node.js below 22.12.0 or Vite below 6.4.0. The current getting-started guide lists those versions as minimums (requirements).
  • You need to move a Jest suite without reviewing test setup assumptions. The migration guide documents differences in globals, module mocks and mock reset behaviour that call for reviewing suites that depend on them (Jest migration guide).

Current state

Vitest 5.1.2 was released on 2026-11-25 (release notes). The licence is MIT (repository licence).

Setup

Run npm install -D vitest. Add "test": "vitest" to your package scripts, import expect and test from vitest in a .test.js file, and run npm test (getting started).

Watch out for

Node is the default test environment. jsdom and happy-dom emulate browser APIs, and Browser Mode is a separate choice for executing in a browser (environments, Browser Mode). In Browser Mode, native ESM seals the module namespace object. The module mocking guide shows vi.mock(..., { spy: true }) when you want to track export calls while keeping the original implementations (module mocking). In Vitest 5, clearMocks defaults to true. Call history recorded in a beforeAll hook can therefore be cleared before the test that inspects it (Vitest 5 migration).

Vitest on GitHub