The node:test module is Node's built-in test runner, also invoked as node --test
Answer: The node:test module facilitates the creation of JavaScript tests. Import it with import test from 'node:test' or require('node:test'). This module is only available under the node: scheme. If any tests fail, the process exit code is set to 1.
Command line and test shapes
From the command line, pass the --test flag, as in node --test. By default Node.js runs files matching patterns such as */.test.js and /test//*.js. You can also pass glob patterns as arguments, in double quotes so the shell does not expand them.
A test is a single function, handled in one of three ways: a synchronous function (fails if it throws), a function that returns a Promise (fails if the Promise rejects), or a function that takes a callback (fails if the callback receives a truthy first argument). describe() and it() are aliases for writing suites and tests.
See also
Claims
- id: C1 claim: The node:test module is used to create JavaScript tests. source: S1 evidence: "node:test"
- id: C2 claim: Invoke the test runner from the command line with node --test. source: S1 evidence: "node --test"
- id: C3 claim: The node:test module facilitates the creation of JavaScript tests. source: S2 evidence: "The
node:testmodule facilitates the creation of JavaScript tests."
- id: C4 claim: If any tests fail, the process exit code is set to 1. source: S2 evidence: "If any tests fail, the process exit code is set to
1."
Sources
- [S1] Test runner. Node.js docs. https://nodejs.org/api/test.html . License: MIT. Accessed 2026-11-17.
- [S2] test.md (Node.js source docs). nodejs/node (GitHub). https://github.com/nodejs/node/blob/main/doc/api/test.md . License: MIT. Accessed 2026-11-17.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Node.js docs, Test runner, MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE); nodejs/node (GitHub), test.md (Node.js source docs), MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js docs, Test runner, MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE); nodejs/node (GitHub), test.md (Node.js source docs), MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE).
Cite this
iinventedlight. 2026. "The node:test module is Node's built-in test runner, also invoked as node --test." iinventedlight Library, iil:note:js7yz3n2, version of 2026-11-17. https://iinventedlight.com/library/notes/node-test-runner/. License: CC-BY-4.0.
@misc{iil_note_js7yz3n2,
author = {{iinventedlight}},
title = {{The node:test module is Node's built-in test runner, also invoked as node --test}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-17},
url = {https://iinventedlight.com/library/notes/node-test-runner/},
note = {Permanent ID iil:note:js7yz3n2. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- node-test-runner.table.json (table; CC-BY-4.0)
- node-test-runner.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/node-test-runner.md.