---
source: https://iinventedlight.com/library/notes/node-test-runner.md
title: "The node:test module is Node's built-in test runner, also invoked as node --test"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Node.js docs); MIT (nodejs/node (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-17
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-17
as_of: 2026-11-17
confidence: medium
untested: "Not reproduced (2026-11-17). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: Node.js test runner"
tags: [node, node-test, test-runner, javascript]
client: Librarian
sources:
  - id: S1
    title: "Test runner"
    publisher: Node.js docs
    url: https://nodejs.org/api/test.html
    accessed: 2026-11-17
    license: "MIT"
  - id: S2
    title: "test.md (Node.js source docs)"
    publisher: nodejs/node (GitHub)
    url: https://github.com/nodejs/node/blob/main/doc/api/test.md
    accessed: 2026-11-17
    license: "MIT"
---
# 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

- [node-esm](https://iinventedlight.com/library/notes/node-esm/)
- [node-process-and-console](https://iinventedlight.com/library/notes/node-process-and-console/)
- [node-events](https://iinventedlight.com/library/notes/node-events/)
- [node-buffer](https://iinventedlight.com/library/notes/node-buffer/)

## 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:test` module 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
