A 4,000-test suite that takes 11 minutes locally and 40 minutes in CI is not a testing problem — it is a runner problem. Most JavaScript teams picked their test framework in 2019 and have been paying transform and module-resolution tax ever since. In 2026 there are four credible options, and three of them are meaningfully faster than the one most teams still use.

The numbers that frame the decision: Jest has 45,475 stars, Mocha 22,906, Vitest 17,475, and Node’s built-in runner ships inside a runtime with 124,034 stars and needs no dependency at all.

TL;DR: The 60-Second Verdict

  • New project, Vite anywhere in the stack → Vitest. Native ESM and TypeScript, no transform config, watch mode that feels instant.
  • Established monorepo already on Jest → stay on Jest until the migration cost is smaller than the CI savings. Jest is not broken; it is just slow to boot.
  • Library with a handful of test files, zero dependencies wanted → node:test. It is stable, built in, and fast enough.
  • Legacy browser suite or a custom runner pipeline → Mocha, mostly because you have already paid the setup cost.

Everything else is a nuance. If you are choosing today with no legacy constraints: Vitest, and it is not close.

Comparison Table: Runner Reality Check

DimensionVitestJestMochanode:test
GitHub stars17,47545,47522,906ships in Node.js (124,034)
LicenseMITMITMITMIT
Last push2026-11-262026-11-252026-11-252026-11-26
Native ESMYesPartial, needs flagsYesYes
TypeScript out of the boxYes (via Vite)Needs ts-jest or BabelNeeds a loaderYes (Node 22.6+ type stripping)
Transform pipelineViteBabel/ts-jestCustom loadersNone
Built-in mockingvi.*jest.*No (sinon)mock from node:test
Snapshot testingYesYes (originator)No (needs plugin)Yes
Coverage enginev8 or istanbulistanbul or v8c8/nycBuilt-in v8
ParallelismWorker threadsWorker processes--parallel--test-concurrency
Browser modeYes (experimental)jsdomReal browsers via KarmaNo
Config surfacevitest.config.tsjest.config.ts.mocharc.jsonCLI flags only
Cold start on a 200-file suite~1.8 s~9 s~1.2 s~0.4 s

Decision Matrix: Ten Seconds to a Choice

Your situationRecommendedWhy
Vite/React/Vue/Svelte appVitestReuses your existing Vite config; zero duplicate transform setup
Large Jest monorepo with custom reportersJestMigration cost outweighs speed gain
npm library, 20 test filesnode:testNo dev dependencies, no config file, runs everywhere Node runs
Tests need real browsersMocha or Vitest browser modeMocha has the most mature browser story
TypeScript without a build stepVitest or node:testBoth consume TS directly
Coverage gate in CI on a budgetnode:testBuilt-in v8 coverage, no extra package
Need snapshot tests todayVitest or JestBoth are first-class
Legacy Express app on CommonJSJest or MochaBoth handle CJS without ceremony

Vitest: The Default for New Projects

Vitest official project mark

Vitest’s core advantage is architectural: it runs inside Vite’s module graph, so the transform work your dev server already does is reused. No Babel config, no ts-jest, no dual-package headaches.

1
2
3
4
npm install -D vitest @vitest/coverage-v8
npx vitest            # watch mode
npx vitest run        # single pass (CI)
npx vitest run --coverage

A typed config that also fixes the most common path trap:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
// vitest.config.ts
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    environment: "node",
    include: ["src/**/*.test.ts"],
    coverage: {
      provider: "v8",
      reporter: ["text", "lcov"],
      thresholds: { lines: 80, functions: 75 },
    },
    pool: "threads",
    poolOptions: { threads: { singleThread: false } },
  },
  resolve: { alias: { "@": new URL("./src", import.meta.url).pathname } },
});

Mocking is explicit and hoisted, which matters when you are debugging why a mock “did not apply”:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import { describe, it, expect, vi, beforeEach } from "vitest";
import { fetchUser } from "@/lib/users";
import { db } from "@/lib/db";

vi.mock("@/lib/db", () => ({ db: { query: vi.fn() } }));

describe("fetchUser", () => {
  beforeEach(() => vi.clearAllMocks());

  it("returns null for a missing row", async () => {
    (db.query as any).mockResolvedValueOnce([]);
    await expect(fetchUser(42)).resolves.toBeNull();
    expect(db.query).toHaveBeenCalledOnce();
  });
});

Where Vitest hurts: the browser mode is still younger than the alternatives, and some Jest-specific ecosystem plugins (custom reporters, older transformers) have no direct equivalent. If your test suite depends on a Jest plugin nobody maintains anymore, that plugin is your migration blocker.

Jest: Still Default, Still Slow

Jest earned its position and still has the deepest ecosystem. But its architecture is from the Babel era: every file goes through a transform, and each worker boots a full module registry. On a 200-file suite that is roughly 9 seconds of cold start before your first assertion runs.

1
2
npm install -D jest ts-jest @types/jest
npx jest --ci --maxWorkers=50% --shard=1/3
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// jest.config.ts
import type { Config } from "jest";

const config: Config = {
  preset: "ts-jest",
  testEnvironment: "node",
  testMatch: ["**/*.test.ts"],
  collectCoverageFrom: ["src/**/*.ts", "!src/**/*.d.ts"],
  coverageThreshold: { global: { lines: 80 } },
};

export default config;

The one area where Jest still wins outright is ecosystem gravity: every tutorial, every Stack Overflow answer, and every legacy helper assumes it. For a team that inherited 3,000 Jest tests, “faster runner” is not a business case on its own.

Where Jest hurts: ESM. Running native ESM in Jest requires experimental flags and often a second config file, which is exactly the kind of friction that makes teams stop writing tests.

node:test: The Zero-Dependency Runner

Node’s built-in runner reached stability, and for libraries it is now the sane default. Nothing to install, nothing to configure, no version skew between runner and runtime.

1
2
3
node --test                      # discovers **/*.test.js and test/**/*.js
node --test --experimental-test-coverage
node --test --test-concurrency=4
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// src/parse.test.js
import test, { describe, mock } from "node:test";
import assert from "node:assert/strict";
import { parseDuration } from "./parse.js";

describe("parseDuration", () => {
  test("handles minutes and seconds", () => {
    assert.equal(parseDuration("2m30s"), 150);
  });

  test("rejects garbage", () => {
    assert.throws(() => parseDuration("soon"), /invalid duration/);
  });

  test("calls the clock once", () => {
    const now = mock.method(performance, "now", () => 1000);
    assert.equal(parseDuration("1s"), 1400 - now.mock.calls.length);
    now.mock.restore();
  });
});

Where node:test hurts: no config file means less control. Snapshot support exists but is minimal, the assertion output is terser than Vitest’s diff view, and there is no browser story at all. It is a great library runner and a mediocre application runner.

Mocha: The Configurable Veteran

Mocha is a test framework in the old sense: it gives you describe/it and hooks, and you assemble the rest (assertions from chai, spies from sinon, coverage from c8). That flexibility is why it survives in browser suites and unusual pipelines.

1
2
npm install -D mocha chai sinon c8
npx mocha "test/**/*.spec.js" --parallel --timeout 5000
1
2
3
4
5
6
7
8
{
  "require": ["./test/setup.js"],
  "spec": ["test/**/*.spec.js"],
  "timeout": 5000,
  "parallel": true,
  "reporter": "spec",
  "recursive": true
}

Where Mocha hurts: you maintain the assembly. Every capability — coverage, snapshots, mocking, TypeScript — is a separate package with its own version constraints. For a greenfield Node service that is unnecessary work in 2026.

CI Performance: What Actually Moves the Needle

Runner choice is only half the story; these settings matter as much as the framework:

  1. Shard by file count, not by duration. vitest run --shard=1/3 and jest --shard=1/3 split deterministically. Balance later if one shard dominates.
  2. Match worker count to vCPU, not to a fixed number. --maxWorkers=2 on a 4-core runner wastes half the machine; 4 workers on a 2-core runner thrashes.
  3. Turn off coverage on the fast feedback path. Run tests without coverage on every commit, coverage on merge to main.
  4. Cache the transform layer. Vitest gets this from Vite’s cache; Jest needs cacheDirectory on a mounted volume to benefit.
  5. Never run the full suite in watch mode locally and in CI simultaneously — CI should run run (single pass), not watch. It sounds obvious; it is a common 3x slowdown.

If your E2E layer is the slow part, that is a different conversation — see our Playwright vs Cypress vs Selenium comparison. For snapshot mechanics across languages, the snapshot testing deep dive covers the storage and review workflow.

FAQ

Is Vitest a drop-in replacement for Jest?

Mostly, for application test suites. The API surface (describe, it, expect, beforeEach) is compatible, and jest.fn() maps to vi.fn(). The friction points are custom transformers, Jest-specific reporters, and jest.mock path resolution in ESM projects.

Which runner is fastest on a large suite?

Vitest typically wins on cold start and watch-mode re-runs because it reuses Vite’s transform cache. node:test has the lowest absolute overhead but scales less well with heavy mocking. Jest is consistently the slowest to boot.

Should I migrate 3,000 Jest tests to Vitest?

Only if CI time is a real bottleneck and no Jest-specific plugins are in play. A pragmatic path: migrate new packages to Vitest first, keep the legacy suite on Jest, and run both in CI until the old suite shrinks.

Does node:test support TypeScript?

Yes on Node 22.6+ with type stripping enabled, and natively on newer releases. There is no type checking at runtime — run tsc --noEmit separately in CI if you want types enforced.

How do I get coverage without adding a package?

Use node --test --experimental-test-coverage for built-in v8 coverage, or vitest run --coverage with @vitest/coverage-v8. Both emit lcov, which every CI provider understands.

Can I run the same tests in a browser?

Vitest browser mode and Mocha with a browser runner both work. Jest’s jsdom environment is not a real browser — it will not catch layout, CSS, or native event differences.


💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com