← All notes

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

Sources

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

Permanent ID: iil:note:js7yz3n2

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.},
}

Markdown

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.

All artifact files (JSON index)

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.