Node.js Built-in Test Runner (node:test deep features)

Parent: JavaScript and Node.js · researched 2026-06-02T18:17:19.155Z· 6 sources · 7 concepts · skill nodejs-test-runner

This reference is about using node:test as a real test framework — the depth

Overview

1. Test structure: test / describe / it, subtests, and the `TestContext`

2. Lifecycle hooks: before / after / beforeEach / afterEach

3. Mocking functions, methods, getters/setters, and properties

4. Mocking time: `mock.timers`

5. Module mocking: `mock.module()` (experimental)

6. Coverage, reporters, and the filtering / execution model

7. Snapshots and assertions

Practical patterns

Anti-patterns

Troubleshooting

References

Children

Frontier under this node: Coverage, reporters, and the filtering/execution model (--test-* flags, isolation, sharding), Lifecycle hooks: before/after/beforeEach/afterEach (+ hook options), Mocking functions, methods, getters/setters, and properties (mock.fn/method), Mocking time: mock.timers, Module mocking: mock.module() (--experimental-test-module-mocks), Snapshots (t.assert.snapshot) and assertions (node:assert/strict + t.assert.*), Test structure: test/describe/it, subtests, and the TestContext

← the whole tree · 3D view· how to read this page