Package-level declarations
Types
Configuration options for hooks.
The MockFunctionContext class is used to inspect or manipulate the behavior of mocks created via the MockTracker APIs.
Mocking timers is a technique commonly used in software testing to simulate and control the behavior of timers, such as setInterval and setTimeout, without actually waiting for the specified time intervals.
The MockTracker class is used to manage mocking functionality. The test runner module provides a top level mock export which is a MockTracker instance. Each test also provides its own MockTracker instance via the test context's mock property.
An instance of SuiteContext is passed to each suite function in order to interact with the test runner. However, the SuiteContext constructor is not exposed as part of the API.
The type of a suite test function. The argument to this function is a {@link SuiteContext} object.
An instance of TestContext is passed to each test function in order to interact with the test runner. However, the TestContext constructor is not exposed as part of the API.
The hook function. The first argument is a TestContext object. If the hook uses callbacks, the callback function is passed as the second argument.
The type of a function passed to {@link test}. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the second argument.
A successful call to run() will return a new TestsStream object, streaming a series of events representing the execution of the tests.
Functions
This function creates a hook that runs after executing a suite.
This function creates a hook that runs after each test in the current suite. The afterEach() hook is run even if the test fails.
This function creates a hook that runs before executing a suite.
This function creates a hook that runs before each test in the current suite.
Shorthand for marking a test as only. This is the same as calling {@link test} with options.only set to true.
Note: shard is used to horizontally parallelize test running across machines or processes, ideal for large-scale executions across varied environments. It's incompatible with watch mode, tailored for rapid code iteration by automatically rerunning tests on file changes.
Shorthand for skipping a test. This is the same as calling {@link test} with options.skip set to true.
The suite() function is imported from the node:test module.
The node:test/reporters module exposes the builtin-reporters for node:test. To access it:
The test() function is the value imported from the test module. Each invocation of this function results in reporting the test to the TestsStream.
Shorthand for marking a test as TODO. This is the same as calling {@link test} with options.todo set to true.