Vitest 5 vs Jest 30: Jest Won My Benchmark Until I Changed One Flag

📅 November 10, 2026 ⏱ 9 min read
Vitest 5 vs Jest 30: Jest Won My Benchmark Until I Changed One Flag

The 60-second version of this test. Subscribe on YouTube

Vitest 5 shipped on September 3, and 5.1 followed on November 2. The pitch hasn’t changed since Vitest 1: it’s the fast, Vite-native, TypeScript-first test runner, and Jest is the legacy you migrate away from.

So I expected a boring benchmark. I wrote one TypeScript test suite, ran it on both runners with their default settings, and Jest won. Not by a little: Jest finished in 4.1 seconds, Vitest in 14.8.

Then Vitest itself printed a hint at the bottom of the run. I followed it, and Vitest finished in 1.6 seconds. This article is about that flag, why it makes such a difference, and the bug it can hide in your suite.

The Setup

Same code, same tests, same machine. Only the runner changes.

  • Machine: a 4 vCPU cloud container (Intel Xeon @ 2.10 GHz, 15 GB RAM), Node.js 22.23.4.
  • Vitest side: [email protected] and [email protected], with a 5-line config.
  • Jest side: [email protected], @jest/[email protected], and @swc/[email protected] with @swc/[email protected]. Jest can’t run TypeScript on its own, so it needs a transformer. I picked SWC because it’s the fastest common option. The Jest docs list Babel and ts-jest, and [email protected] declares typescript >=4.3 <7 as its peer, so it can’t use TypeScript 7 yet.
  • The suite: 300 test files and 2,700 tests, generated from one template. Each file tests a small cart and checkout module: pure functions, it.each tables, thrown errors, an async payment gateway mock with fn() and mocked(), and a debounce helper under fake timers. That’s what a typical TypeScript service’s unit tests look like. It’s not a real project, and I’ll come back to what that means.
  • Method: 5 rounds per configuration. Each round clears the runner’s caches, runs once (cold), and runs again (warm). I report the median wall-clock time of the whole command, measured from Python with time.perf_counter().

The same test on both sides

The test files are identical except for the import line and the vi/jest object. Here’s one of them, Vitest version:

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { type Line } from '../src/cart.js';
import { Checkout, debounce, type PaymentGateway } from '../src/checkout.js';

const lines: Line[] = [
  { sku: 'A0', unitCents: 100, qty: 2 },
  { sku: 'B0', unitCents: 250, qty: 1 },
];

describe('checkout', () => {
  let gateway: PaymentGateway;
  beforeEach(() => {
    gateway = { charge: vi.fn(async (cents: number, ref: string) => ({ id: ref + ':' + cents })) };
  });

  it('propagates gateway failures', async () => {
    vi.mocked(gateway.charge).mockRejectedValueOnce(new Error('declined'));
    await expect(new Checkout(gateway).pay(lines)).rejects.toThrow('declined');
  });
});

describe('debounce', () => {
  beforeEach(() => { vi.useFakeTimers(); });
  afterEach(() => { vi.useRealTimers(); });

  it('fires once after the quiet period', () => {
    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).toHaveBeenCalledTimes(1);
    expect(spy).toHaveBeenCalledWith('c');
  });
});

The Jest version swaps the first line for import { describe, it, expect, jest, beforeEach, afterEach } from '@jest/globals'; and every vi. for jest.. That’s the whole migration for this kind of test: the APIs are the same shape.

The configs

Vitest:

// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: { include: ['test/**/*.test.ts'] },
});

Jest:

// jest.config.js
/** @type {import('jest').Config} */
export default {
  testEnvironment: 'node',
  testMatch: ['<rootDir>/test/**/*.test.ts'],
  transform: { '^.+\\.ts$': ['@swc/jest'] },
  moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1' },
};

The moduleNameMapper line is there because my source uses .js extensions in imports ('./cart.js'), as Node’s ESM resolution wants. Vite resolves those to .ts files on its own. Jest needs to be told.

Round 1: Defaults

Runner (300 files, 2,700 tests)Cold (median)Warm (median)
Vitest 5.1, default config15.52 s14.83 s
Jest 30.5 + @swc/jest4.50 s4.12 s

On my machine, Jest was 3.6x faster warm. All 2,700 tests passed on both.

Vitest explained why at the end of the run. Vitest 5 prints performance hints by default, and this is what it printed:

 Test Files  300 passed (300)
      Tests  2700 passed (2700)
   Duration  14.63s (tests 39%, import 38%, worker 11%, transform 11%)

    Isolate  300 workers spawned · ~102ms startup each (spawn + environment, per file)
             at least ~10.11s faster with isolate: false — reuses workers across files instead of one per file

By default, Vitest runs each test file in a fresh worker (the forks pool with isolate: true). That’s the safest choice: no state can leak from one file to the next. But each new worker costs about 100 ms on this machine, and 300 files means 300 workers. My test files are small, so that startup cost is most of the run.

Jest also isolates test files, but differently. It reuses a small pool of worker processes and gives each file a fresh module registry inside a vm context. That’s cheaper than a new process per file.

Round 2: Following the Hint

I tried the hint, and the two vm pools that work like Jest:

Runner (300 files, 2,700 tests)Cold (median)Warm (median)
Vitest 5.1, default config15.52 s14.83 s
Vitest 5.1, --pool=vmThreads6.23 s5.45 s
Jest 30.5 + @swc/jest4.50 s4.12 s
Vitest 5.1, --no-isolate2.41 s1.62 s

With isolation off, Vitest ran the suite in 1.62 seconds warm: 2.5x faster than Jest, and 9x faster than its own default. The vmThreads pool, which is the closest to Jest’s model, landed between the two. In a single exploratory run, --pool=vmForks reported the same duration as vmThreads (5.21 s vs 5.25 s), so I didn’t benchmark it separately.

The cold-to-warm gap is Vitest 5’s fsModuleCache, which is now on by default. It stores transformed modules on disk (node_modules/.vitest-cache) so the next run skips the transform step.

To make it permanent, it’s one line:

export default defineConfig({
  test: { include: ['test/**/*.test.ts'], isolate: false },
});

The Catch: What Isolation Was Protecting You From

isolate: false means test files share modules when they run in the same worker. Any module-level state survives from one file to the next. Here’s a minimal case:

// registry.ts
const handlers = new Map<string, () => string>();

export function register(name: string, fn: () => string): void {
  if (handlers.has(name)) throw new Error(`duplicate handler: ${name}`);
  handlers.set(name, fn);
}

export function count(): number {
  return handlers.size;
}
// plugin1.test.ts (plugin2.test.ts is identical)
import { it, expect } from 'vitest';
import { register, count } from './registry';

it('registers the plugin handler', () => {
  register('health', () => 'ok');
  expect(count()).toBe(1);
});

What I got:

RunResult
Vitest, default (isolate: true)2 passed
Jest 30 (--maxWorkers=1)2 passed
Vitest, --no-isolate --maxWorkers=11 failed: Error: duplicate handler: health
Vitest, --no-isolate (default workers)2 passed

The last two rows are the dangerous part. With several workers, the two files happened to land in different workers and both passed. With one worker, they shared the module and the second one failed. So a leak like this doesn’t fail every time. It fails depending on how files are scheduled, which on a CI runner with fewer cores than your laptop looks like a flaky test.

My benchmark suite survives isolate: false because every test rebuilds its mocks in beforeEach, restores real timers in afterEach, and the code under test has no module-level state. Vitest 5 also helps here: clearMocks now defaults to true, so mock call history is reset before each test. But module-level caches, singletons, registries and patched globals in your own code aren’t reset by anything.

Where Each Runner Wins

Where Vitest 5 wins

  • Raw speed, if your tests are clean. With isolate: false, it was 2.5x faster than Jest on my suite.
  • TypeScript with no extra packages. Vitest transforms TypeScript through Vite. Jest needs a transformer package and, for .js-suffixed imports, a moduleNameMapper entry.
  • A much smaller install. On a clean npm install, the Vitest side installed 35 packages (40 MB of node_modules). The Jest side installed 285 packages (66 MB).
  • It tells you what to change. The isolate hint above told me exactly which option to try and estimated the gain (at least 10.1 s, and I measured 13.2 s).

Where Jest 30 wins

  • Fast and safe by default. On my suite, Jest’s defaults were 3.6x faster than Vitest’s defaults, with isolation still on.
  • Old suites with hidden state. If your tests were written for Jest’s per-file module registry, they may quietly depend on it. Turning off Vitest’s isolation can surface leaks as flaky failures, like the registry example above.
  • No Vite in the loop. If your project isn’t built with Vite, Jest plus SWC is a small, well-known setup that doesn’t add a bundler’s config to your test story.

Decision Table

Your situationMy pick
New TypeScript projectVitest 5, with isolate: false from day one, so leaks show up while the suite is small
Vite-based frontend or libraryVitest 5. You already have the config, and you get the same transforms in tests and builds
Large Jest suite, green and stableStay on Jest 30 until you have time to audit module-level state
Migrating from JestVitest 5, but migrate with isolation on first, then turn it off and fix what breaks
Need TypeScript 7 in your test pipelineVitest 5, or Jest with SWC or Babel. Not ts-jest, whose peer range stops below 7

The Verdict

Vitest 5 wins this clash, by 2.5x, but only after you change one setting and accept the responsibility that comes with it. With its default configuration, Vitest lost to Jest by 3.6x on my 4-core machine, because spawning a fresh worker per test file costs more than the tests themselves.

If you’re comparing the two by running your suite once with defaults, you may come away thinking Vitest is slow. It isn’t. It’s paying for isolation in the most expensive way. Read the hint it prints, decide whether your tests can live without per-file isolation, and measure again.

A caveat on these numbers: this is a generated suite of small, fast unit tests on one machine. Real suites with heavier imports, DOM environments or slow tests will move these numbers, and more cores will shrink the per-file spawn cost. The method is easy to copy: same tests, both runners, caches cleared, median of five.


More TypeScript tooling clashes:

💡

Enjoying the content? Here are tools I personally use and recommend:

  • 🌐 Hosting: Bluehost — simple hosting for a WordPress or PHP site
  • 🛒 Tech Gear: My Amazon Store — keyboards, monitors, dev tools I use

Purchases through my links help keep this blog ad-free 💙

Enjoyed this post?

Every clash gets a video: two tools, one real task, a measured winner.

▶ Subscribe on YouTube 🎬 All videos