The pitch for Node's built-in test runner is one less dependency: one less entry in package.json to keep updated and in sync with your Node version. That pitch holds up well for a backend package. It falls apart the moment you need to render a React component in a test, and the rest of this comparison is about where that line sits.
The same test in Jest and node:test
// Jest
import { describe, it, expect, jest } from '@jest/globals';
import { formatPrice } from './pricing.js';
describe('formatPrice', () => {
it('formats cents as dollars', () => {
expect(formatPrice(1999)).toBe('$19.99');
});
it('calls the logger on invalid input', () => {
const logSpy = jest.fn();
formatPrice(-1, { onError: logSpy });
expect(logSpy).toHaveBeenCalledTimes(1);
});
});
// node:test, zero dependencies
import { describe, it, mock } from 'node:test';
import assert from 'node:assert/strict';
import { formatPrice } from './pricing.js';
describe('formatPrice', () => {
it('formats cents as dollars', () => {
assert.strictEqual(formatPrice(1999), '$19.99');
});
it('calls the logger on invalid input', () => {
const logSpy = mock.fn();
formatPrice(-1, { onError: logSpy });
assert.strictEqual(logSpy.mock.calls.length, 1);
});
});
The structure is nearly identical, describe/it survived the transition unchanged. The real difference is expect(x).toBe(y) versus assert.strictEqual(x, y), and jest.fn() versus mock.fn(). If your team already thinks in Jest's expect API, that's a real (if small) retraining cost across a whole test suite. A built-in test runner is a testing framework shipped directly inside the language runtime rather than installed as a separate package, and node:test is exactly that: it's been part of Node.js core, stable, since Node 20, according to the Node.js docs. That matters practically because node:assert has existed in Node since the very first releases, so node --test is really pairing two already-stable pieces of the runtime rather than introducing new surface area, which is part of why the migration path from Jest tends to be mechanical rather than risky.
If your team already thinks in Jest's expect API, switching to node:test's assert.strictEqual is a real, if small, retraining cost across a whole test suite, even though the underlying test structure, describe and it blocks, transfers over unchanged.
Running it
node --test
node --test --experimental-test-coverage
node --test src/**/*.test.ts # TypeScript directly, no build step, Node 23.6+
I reran this on November 20 with a small .ts test file on Node 22.23.5, 24.21.0 and 26.10.0: node --test ran it with no flag on all three, t.mock.timers, t.assert.snapshot() and mock.fn() passed, and --experimental-test-coverage printed a coverage table. The flag was still spelled the experimental way on 26.10.0, where --test-coverage is rejected as a bad option. No config file, no jest.config.js, no transform setup for TypeScript. The missing transform is the part I'd weigh most: a Jest + TypeScript setup needs ts-jest or a Babel transform configured correctly, a source of its own recurring version-compatibility headaches. node --test running .ts files directly sidesteps that entire category of configuration problem. Per the Node.js documentation, native TypeScript execution landed as a default-on feature in Node 23.6, after shipping earlier behind the --experimental-strip-types flag on Node 22.x. Type stripping only removes type annotations at parse time, it does not transform syntax, so features that require actual code generation, enums and namespaces among them, still need the separate --experimental-transform-types flag or a real build step. That flag is gone on Node 26: I ran an enum test file on 22.23.5, 24.21.0 and 26.10.0, and all three refuse it with ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX, but only 22 and 24 accept the flag that fixes it, while 26.10.0 answers bad option. On 26, an enum means a build step or a rewrite as a plain object. In practice that limitation bites less often than you'd expect, since most modern TypeScript code avoids enums and namespaces anyway.
Where the built-in runner falls short
// This needs a DOM. node --test has no built-in DOM environment.
import { render, screen } from '@testing-library/react';
import { describe, it } from 'node:test';
import { LoginForm } from './LoginForm.jsx';
describe('LoginForm', () => {
it('shows a validation error', () => {
render(<LoginForm />); // fails: no `document` in the node:test environment
// ...
});
});
Jest and Vitest both integrate jsdom (or happy-dom for Vitest) as a configurable test environment, providing a document, window, and the DOM APIs a rendered React component needs. node --test runs in a plain Node.js environment with none of that, and the Node.js test runner docs describe no DOM environment or plan for one. For component-level frontend testing, that gap decides the choice. A DOM environment means a simulated document and window object good enough to let a component-testing library render markup and query it without a real browser, and it is the one piece of test infrastructure the built-in runner does not attempt to provide. For components rendered on the server, the built-in runner does pair well with a real database, since node:sqlite as a test database needs no install and no mock.
Mocking: Jest vs node:test
| Feature | Jest | node:test |
|---|---|---|
| Function mocks | jest.fn() | mock.fn() |
| Module mocks | jest.mock('./module') | mock.module() (Node 22.3+, behind --experimental-test-module-mocks) |
| Timer mocks | jest.useFakeTimers() | mock.timers.enable() |
| Snapshot testing | Built-in, mature | Built-in since Node 22, fewer format options |
| DOM environment | jsdom/happy-dom via config | None built-in |
mock.module() is the newest and least mature entry here. On Node 22.23.5, 24.21.0 and 26.10.0 it is undefined until you pass --experimental-test-module-mocks, and the 26.x docs still label it "Early development". Module mocking in the built-in runner still has rough edges around ESM interop that Jest's older, CommonJS-era mocking system doesn't share. If your test suite leans heavily on mocking entire modules rather than individual functions, that's worth testing carefully before committing to a full migration. The API shapes differ enough to matter during a port. Jest gives you jest.fn(), jest.spyOn(), and jest.mock() as three separate entry points, while the built-in runner puts all of it behind a single mock object imported from node:test, with mock.fn(), mock.method(), and mock.module() as the equivalents. Restoring behaviour differs too: Jest leans on config flags like restoreMocks, whereas node:test automatically restores mocks created through the test context (t.mock) when that test finishes and gives you mock.reset() and mock.restoreAll() for the top-level mock object. Neither is harder, but a mechanical find-and-replace won't get you there.
mock.module() shipped in Node 22.3 and is still marked experimental, with rough edges around ESM interop that Jest's older CommonJS-era module mocking does not share, so heavy module-mocking suites should test the migration carefully before committing to it.
Which one to use
- Node-only backend package, CLI tool, or library with no DOM dependency:
node --testcovers it, and removing a dependency is a real, if modest, win for install time and maintenance surface. - Frontend app with React/Vue components under test: Jest or Vitest, the DOM environment isn't optional. Vitest specifically integrates well if you're already on Vite for the build.
- Mixed monorepo, some packages backend-only, some frontend: it's reasonable to use
node --testfor the backend packages and Vitest for the frontend ones, rather than forcing one runner across a codebase where the two halves have genuinely different needs.
That last split is the one I actually run, and the friction is far lower than it sounds. In my own monorepo it's Vitest for the shared TypeScript library and a separate runner for the content-validation tier, and the two only ever meet as two lines in CI. On one workspace that second suite executes 15,025 assertions in 13 seconds while the build in front of it takes about 60, so the runner isn't the expensive part of that pipeline.
If I were starting a Node-only package today, I wouldn't install a runner at all. Start with node --test, and let the first test that genuinely needs a document be the thing that buys Vitest, rather than paying for it up front out of habit.
One question settles this faster than any feature matrix: does anything in the suite need a document or a window? If the answer is no, the built-in runner is a genuine option and you get to delete somewhere between 3 and 5 devDependencies along with a config file. If the answer is yes for even a handful of tests, you need Jest or Vitest for those, and the only real decision left is whether to run 2 runners side by side or keep one for everything. Teams underestimate how workable the split is in a monorepo, where each package already has its own test script and nobody has to think about which runner is in play.
How to decide, step by step:
- Check whether any test in the suite renders a component or touches the DOM.
- If none do, run
node --testagainst the existing suite and see how many assertions need only a mechanicalexpecttoassertswap. - If some tests need a DOM, split the suite:
node --testfor backend packages, Jest or Vitest for anything rendering UI. - Re-evaluate yearly. The Node 26 docs still list no DOM environment for the built-in runner.
The decision between node:test and Jest or Vitest comes down to one question: does any test in the suite need a document or window object, since that single dependency is the one gap the built-in runner has no roadmap to close.