Vitest vs node:test: Which JS Test Runner?
Vitest is a fast, Vite-powered test framework with rich features; node:test is the built-in, zero-dependency runner shipped with Node.
Vitest reuses your Vite config and transforms, runs tests in parallel with watch mode, and offers a Jest-like API, mocking, coverage, and snapshot testing - ideal for Vite/TS projects. node:test is built into modern Node, needs no dependencies, and covers core needs (test, subtests, assertions via node:assert, basic mocking), but is more minimal. Vitest is feature-rich; node:test is lean and dependency-free.
| Vitest | node:test | |
|---|---|---|
| Dependencies | Vitest + Vite | None (built in) |
| Features | Mocks, snapshots, coverage | Core testing |
| TS / Vite | First-class | Manual transform |
| Watch mode | Fast HMR | Basic |
| Best for | Vite/TS apps | Lean, zero-dep tests |
In CI
Vitest fits projects already on Vite or wanting a full-featured runner with coverage and snapshots; it parallelizes well in CI. node:test is attractive for libraries that want no test dependencies and fast startup, though you handle TS transforms and coverage (via c8) yourself. Choose Vitest for app feature depth, node:test for minimal footprint.
Speed it up
Cache dependencies and shard tests across jobs to cut wall-clock time. Both run on CI runners; faster managed runners shorten the test execution and transform steps.
The verdict
Building a Vite or TypeScript app and wanting mocks, snapshots, and coverage out of the box: Vitest. Writing a library that values zero dependencies and fast startup: node:test. Most app teams pick Vitest; minimalists and lib authors increasingly use node:test.