For a new TypeScript or ESM project in December 2026, pick Vitest. It runs .ts and native ESM with no extra flags, and its API covers almost all of Jest's. Jest is still a good choice for large CommonJS codebases, React Native, and teams with years of custom Jest transforms and reporters. This comparison covers the current versions (Vitest 5.1.2, Jest 30.5.2), how each handles ESM and TypeScript, and the migration steps that actually break. I built the same small project with both and ran it, so the configs and output below are real.
Vitest vs Jest at a Glance (December 2026)
| Vitest | Jest | |
|---|---|---|
| Current version (npm, 2 Dec 2026) | 5.1.2 (5.0.0 shipped 3 Sep 2026) | 30.5.2 (30.0.0 shipped 10 Jun 2025) |
| Node.js support | ^22.12.0 \|\| ^24.0.0 \|\| >=26.0.0 |
^18.14.0 \|\| ^20.0.0 \|\| ^22.0.0 \|\| >=24.0.0 |
| ESM | Native, through Vite's module graph | Experimental, needs --experimental-vm-modules |
| TypeScript | Built in (Vite transform, no type checking) | Needs a transform: ts-jest, babel-jest or @swc/jest |
| Config | vitest.config.ts or the test key in vite.config.ts |
jest.config.{js,ts,mjs,json} or package.json |
Globals (describe, it) |
Opt-in (globals: true) or import from vitest |
Injected by default (not in ESM mode for jest) |
| Mock API | vi.fn, vi.mock, vi.spyOn, vi.when (new in 5) |
jest.fn, jest.mock, jest.spyOn, jest.unstable_mockModule for ESM |
| Real-browser runs | Browser Mode (stable since Vitest 4) with Playwright, WebdriverIO or preview providers | None; jsdom or happy-dom simulation only |
| Coverage | v8 (default) or istanbul |
babel (istanbul, default) or v8 |
| Monorepos | projects with config inheritance |
projects |
Version numbers and release dates come from the npm registry. The Node ranges are the engines fields of the two packages. Vitest 5 also needs Vite 6.4 or later. Its peer range accepts Vite 6, 7 and 8, and a fresh install gave me Vite 8.4.0.
What Changed Recently: Vitest 5 and Jest 30
Jest 30 was the first major release in almost three years. It drops Node 14, 16, 19 and 21. It moves jest-environment-jsdom from jsdom 21 to 26, which breaks code that reassigns window.location. It also adds TypeScript config files, .mts/.cts support, and import.meta in native ESM. Jest's ESM docs still describe ESM support as "experimental". Since Node 24.9, require() of an ES module works inside Jest, and automocking reaches ESM graphs that can be evaluated synchronously.
Vitest 5 is mainly a performance release, and several of its changes affect migrations:
clearMocksnow defaults totrue, so call history is wiped before every test. Jest's default is stillfalse.- If you call
resolves,rejectsortoMatchFileSnapshotwithoutawait, the test now fails. Before 5 it only warned. - Inline
projectsinherit the root config by default. vi.when()sets a return value per argument set, andtoHaveBeenExhausted()asserts on it.- Fake timers now mock
Temporalas well asDate. --repeatsreruns tests to flush out flakes, andvitest doctorsuggests a faster configuration.- Reports and artifacts now go to a single
.vitestdirectory.
The full list is in the Vitest 5 migration guide. If you are coming from Vitest 4, check the hoisting rule: vi.mock calls must now sit at the top level.
Hands-On: The Same Project in Both Runners
I wanted to see the real friction, not the marketing version, so I built a small ESM TypeScript project ("type": "module") on Node 24.15. It has two source files. price.ts fetches an exchange rate and formats currency. checkout.ts calls fetchRate, and also exports a debounce helper. Each runner got one test file covering the three things most suites do: mock an imported module, control timers, and snapshot an object.
// src/checkout.ts
import { fetchRate, formatPrice } from './price.js';
export async function quote(cents: number, currency: string) {
const { rate } = await fetchRate(currency);
const converted = Math.round(cents * rate);
return { currency, converted, label: formatPrice(converted, currency) };
}
export function debounce<T extends (...args: any[]) => void>(fn: T, ms: number) {
let t: ReturnType<typeof setTimeout> | undefined;
return (...args: Parameters<T>) => {
clearTimeout(t);
t = setTimeout(() => fn(...args), ms);
};
}
Vitest config and test
Vitest needed one dev dependency and a five-line config. TypeScript, ESM and the .js import specifiers in TypeScript sources all worked without extra setup.
// vitest.config.ts
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
include: ['test-vitest/**/*.test.ts'],
environment: 'node',
coverage: { provider: 'v8', include: ['src/**'] },
},
});
// test-vitest/checkout.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { quote, debounce } from '../src/checkout.js';
import { fetchRate } from '../src/price.js';
vi.mock('../src/price.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../src/price.js')>();
return { ...actual, fetchRate: vi.fn() };
});
describe('quote', () => {
beforeEach(() => {
vi.mocked(fetchRate).mockResolvedValue({ currency: 'EUR', rate: 0.92 });
});
it('converts and formats', async () => {
const result = await quote(1999, 'EUR');
expect(fetchRate).toHaveBeenCalledWith('EUR');
expect(result).toMatchInlineSnapshot(`
{
"converted": 1839,
"currency": "EUR",
"label": "€18.39",
}
`);
});
});
describe('debounce', () => {
it('fires once after the wait', () => {
vi.useFakeTimers();
const spy = vi.fn();
const d = debounce(spy, 200);
d('a'); d('b'); d('c');
vi.advanceTimersByTime(199);
expect(spy).not.toHaveBeenCalled();
vi.advanceTimersByTime(1);
expect(spy).toHaveBeenCalledOnce();
expect(spy).toHaveBeenCalledWith('c');
vi.useRealTimers();
});
});
vi.mock is hoisted above the imports, so the static import { quote } already receives the mocked price.js. The importOriginal helper keeps formatPrice real.
RUN v5.1.2 /…/lab/vj
Snapshots 1 written
Test Files 1 passed (1)
Tests 2 passed (2)
Duration 105ms (tests 52%, transform 34%, import 11%, worker 3%)
Jest config and test
Jest needed more parts. You need a transformer for TypeScript, extensionsToTreatAsEsm, a moduleNameMapper that strips the .js extension so Jest can find the .ts file, and the Node flag.
// jest.config.ts
import type { Config } from 'jest';
const config: Config = {
testMatch: ['<rootDir>/test-jest/**/*.test.ts'],
testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1' },
transform: {
'^.+\\.ts$': ['ts-jest', { useESM: true }],
},
collectCoverageFrom: ['src/**/*.ts'],
};
export default config;
{
"type": "module",
"scripts": {
"test:vitest": "vitest run",
"test:jest": "NODE_OPTIONS=--experimental-vm-modules jest"
}
}
In native ESM, jest.mock is not hoisted and does not apply to ES modules. You register the mock with jest.unstable_mockModule and then load the code under test with a dynamic import():
// test-jest/checkout.test.ts
import { describe, it, expect, jest, beforeEach } from '@jest/globals';
// Load the real module first; importing it inside the factory deadlocks.
const actual = await import('../src/price.js');
const fetchRate = jest.fn<typeof actual.fetchRate>();
jest.unstable_mockModule('../src/price.js', () => ({ ...actual, fetchRate }));
const { quote, debounce } = await import('../src/checkout.js');
describe('quote', () => {
beforeEach(() => {
fetchRate.mockResolvedValue({ currency: 'EUR', rate: 0.92 });
});
it('converts and formats', async () => {
const result = await quote(1999, 'EUR');
expect(fetchRate).toHaveBeenCalledWith('EUR');
expect(result).toMatchInlineSnapshot(`
{
"converted": 1839,
"currency": "EUR",
"label": "€18.39",
}
`);
});
});
The timer test is the Vitest one with vi replaced by jest, except that toHaveBeenCalledOnce() becomes toHaveBeenCalledTimes(1).
The two gotchas I actually hit
Jest exited with code 0 and printed nothing. My first Jest version did what Vitest's importOriginal does: it called await import('../src/price.js') inside the unstable_mockModule factory for that same module. Jest printed only Node's ExperimentalWarning: VM Modules is an experimental feature, ran no tests, wrote no results file, and exited with status 0. A CI job would have gone green with zero tests run. Loading the real module once before registering the mock, as in the code above, fixed it. If you migrate in the other direction, from Vitest to Jest ESM, this is the first thing to check. In any case, make CI fail when the test count is zero.
npm i -D typescript ts-jest no longer resolves. typescript@latest on npm is now 7.0.2, the Go-based compiler. ts-jest@29.4.15 declares typescript >=4.3 <7 as a peer dependency, so npm stops with ERESOLVE unable to resolve dependency tree ... peer typescript@">=4.3 <7" from ts-jest@29.4.15. I pinned typescript@5.9.3. You can also move Jest to @swc/jest or babel-jest, which strip types without calling the TypeScript compiler API. Vitest is not affected, because Vite strips types itself. Our TypeScript 7 migration guide covers which other tools depend on the old compiler API.
Snapshots and speed
Both runners wrote the same serialized object: no Object prefix, sorted keys, and trailing commas. Jest dropped the Object { prefix with the Jest 29 snapshot format change, and Vitest uses the same defaults. Indentation differed. Vitest indented the inline snapshot to match the surrounding code. Jest 30 wrote it flush-left, as shown above. Neither format is wrong, but a migration will rewrite every inline snapshot. Review that as its own diff, not mixed into logic changes.
On speed, I timed five warm runs of each command through npx, wall clock, on an Apple M5 with Node 24.15. Vitest took 0.31 to 0.37 seconds and Jest took 0.48 to 0.66 seconds. That is my measurement on a two-test project, where most of the time is process startup, so it tells you almost nothing about a 5,000-test suite. Measure on your own codebase, using --shard on both runners in CI if you need to.
API Compatibility and Migration Steps
Vitest's Jest migration guide lists the differences. These are the ones that cause most failed migrations, in the order you will run into them:
| Jest | Vitest | Notes |
|---|---|---|
jest.fn(), jest.spyOn() |
vi.fn(), vi.spyOn() |
Mechanical rename |
| Globals on by default | globals: true or explicit imports |
Without globals, Testing Library's automatic cleanup does not run |
jest.mock(path, () => 'x') |
vi.mock(path, () => ({ default: 'x' })) |
Vitest factories must return every export explicitly |
jest.requireActual() |
await vi.importActual() or importOriginal |
Async in Vitest |
__mocks__ applied automatically |
Only after vi.mock(path) |
Put the calls in setupFiles to match Jest |
mockReset() → empty function returning undefined |
mockReset() → restores the original implementation |
A silent behavior change |
jest.setTimeout(5000) |
vi.setConfig({ testTimeout: 5_000 }) |
|
jest.replaceProperty |
vi.stubEnv / vi.spyOn |
|
done callback |
async test or new Promise(done => …) |
Vitest has no callback style |
| Legacy fake timers | Not supported | Modern timers only |
jest.Mock<…> type |
import type { Mock } from 'vitest' |
No jest namespace |
-t 'math adds' |
-t 'math > adds' |
Vitest 5 matches the >-joined full name |
JEST_WORKER_ID |
VITEST_POOL_ID / VITEST_WORKER_ID |
Hooks also behave differently. Vitest runs beforeEach/afterEach as a stack by default, while Jest runs them in list order. Set sequence.hooks: 'list' if your tests depend on Jest's order. A beforeEach that returns a value is treated as a teardown function in Vitest, so wrap one-liners in braces.
A migration order that works:
- Install
vitest. Addtest.globals: trueand"types": ["vitest/globals"]intsconfig.jsonso you don't have to touch every file on day one. - Run the suite with
vitest runand let it fail. Most failures fall into three groups: mock factories missingdefault,requireActual, anddonecallbacks. - Replace
jest.withvi.using a codemod or search-and-replace, then fix the type imports. - Set
clearMocks: falseat first if your tests assert on call counts that accumulate across tests (Vitest 5's default istrue). Remove that override once the suite passes. - Regenerate snapshots with
vitest run -uin a separate commit and review the diff. - Delete
jest.config.*,ts-jest/babel-jest, and the--experimental-vm-modulesflag.
Browser Mode vs jsdom
This is the biggest functional difference. Vitest Browser Mode has been stable since Vitest 4. It runs component tests in a real Chromium, Firefox or WebKit through a provider package:
import { defineConfig } from 'vitest/config'
import { playwright } from '@vitest/browser-playwright'
export default defineConfig({
test: {
browser: {
provider: playwright(),
enabled: true,
instances: [{ browser: 'chromium' }],
},
},
})
Vitest 5 added a Trace View (browser.traceView) that replays steps with DOM snapshots, and locators are now strict by default. Jest has nothing comparable. It runs in Node with jsdom or happy-dom, so layout, real focus handling, IntersectionObserver and CSS behave approximately at best. If you are migrating mainly to test real browser behavior, choose between Browser Mode for components and a full end-to-end runner for user flows. Browser Mode runs on the same Vite pipeline as your app, so the Vite 8 migration guide applies to your test setup too.
Coverage Providers
Vitest's default provider is v8 (package @vitest/coverage-v8). istanbul is available, and in Vitest 5 it moved to the maintained @vitest/istanbuljs packages. Jest defaults to babel (Istanbul instrumentation) and accepts --coverageProvider=v8.
On the same tests, both using V8 data, the two runners reported different numbers:
Vitest 5.1.2 (v8) Jest 30.5.2 (--coverageProvider=v8)
All files 66.66% stmts All files 84.61% stmts
33.33% branch 100% branch
price.ts 20% stmts price.ts 63.63% stmts
Both flag the body of fetchRate, which the mocked test never runs, as uncovered. They disagree on how many statements and branches exist, because Vitest remaps V8 data onto the source AST and Jest's V8 path converts it differently. Don't compare coverage numbers across runners, and reset your thresholds when you migrate. Otherwise CI will either fail without reason or hide a real drop.
Watch Mode and Monorepos
vitest without arguments starts watch mode in an interactive terminal and reruns only the tests affected by the files you changed, using Vite's module graph. In CI it runs once. --changed and the newer --sinceLastRun cover pre-commit hooks. Jest's --watch uses git or Mercurial to find changed files, and --watchAll falls back to everything.
For monorepos, both support projects. Vitest 5 changed the inheritance rules. Inline projects now inherit root options such as plugins and pool, unless you set extends: false. Arrays like setupFiles are concatenated, not replaced. Projects referenced by file or directory do not inherit. The older workspace option has been deprecated since Vitest 3.2 in favour of projects.
// vitest.config.ts at the repo root
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
projects: [
'packages/*',
{
test: { name: 'dom', environment: 'happy-dom', include: ['apps/web/**/*.test.tsx'] },
},
],
},
})
Nx ships a Vitest plugin, and Turborepo simply runs each package's test script, so both work with either runner. Our Nx vs Turborepo comparison covers task caching, which matters more for test time than the runner does. Package managers also handle Vite's large dependency tree differently, as described in our pnpm vs npm vs Yarn vs Bun guide.
When Jest Is Still the Right Call
- React Native. The RN preset and most of its mocks assume Jest.
- Large CommonJS codebases that already have stable
babel-jestsetups and hundreds ofjest.mockfactories. Migrating adds risk without a clear payoff. - Custom Jest reporters, environments or resolvers that your CI or compliance tooling depends on.
- Node 18 or 20 in production. Vitest 5 requires Node 22.12 or later. Our Node.js 26 LTS guide covers upgrading.
Choose Vitest for anything built on Vite, anything ESM-first, and any project where you want component tests in a real browser without a separate tool. Full end-to-end tests still need a browser runner; our Playwright vs Cypress comparison covers that choice.
Frequently Asked Questions
Is Vitest a drop-in replacement for Jest?
Close, but not quite. The expect API, snapshot format and most mock methods match. Mock factories, requireActual, mockReset semantics, done callbacks and automatic __mocks__ loading all differ, and these need code changes. With globals: true, most suites need a rename plus a few dozen targeted fixes.
Does Jest support ESM in 2026?
Yes, but the docs still call it experimental. You must run Node with --experimental-vm-modules, use jest.unstable_mockModule and dynamic import() instead of hoisted jest.mock, and import jest from @jest/globals. Jest 30 on Node 24.9 or later added require(esm) and automocking for synchronous ESM graphs.
Can I use TypeScript 7 with Jest?
Not with ts-jest@29.4.15, whose peer range stops below TypeScript 7. Either keep TypeScript 5.9 or 6.x for the transform, or switch to @swc/jest or babel-jest, which strip types without calling the compiler API. Vitest uses Vite's own transform and is not affected.
Is Vitest faster than Jest?
On my two-test ESM project, Vitest's end-to-end run was about 0.15 to 0.3 seconds faster, but that mostly measures process startup. On large suites the result depends on the pool (threads, forks, vmThreads), the environment (jsdom is slow in both) and isolation settings. Vitest 5 publishes its own benchmarks, and those are vendor-reported. Benchmark your own suite before deciding on speed alone.
Does Vitest type-check my tests?
Not by default. Vite strips types without checking them. Run vitest --typecheck for type-level tests, or keep tsc --noEmit as a separate CI step. Jest with babel-jest or @swc/jest doesn't type-check either. Only ts-jest does, and that is one reason it is slower.
Bottom Line
The Vitest vs Jest decision is mostly settled for new code. Vitest 5 handles ESM and TypeScript with no extra setup, has a stable real-browser mode, and has the more active release cycle. Jest 30 is solid and still the default for React Native and established CommonJS suites, but ESM support still needs an experimental Node flag and a different mocking API. If you migrate, budget most of the time for mock factories and snapshot rewrites, reset coverage thresholds, and make CI fail when zero tests run.