{
  "type": "module",
  "source": "doc/api/test.md",
  "modules": [
    {
      "textRaw": "Test runner",
      "name": "test_runner",
      "introduced_in": "v18.0.0",
      "meta": {
        "added": [
          "v18.0.0",
          "v16.17.0"
        ],
        "changes": [
          {
            "version": "v20.0.0",
            "pr-url": "https://github.com/nodejs/node/pull/46983",
            "description": "The test runner is now stable."
          }
        ]
      },
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p><strong>Source Code:</strong> <a href=\"https://github.com/nodejs/node/blob/v23.7.0/lib/test.js\">lib/test.js</a></p>\n<p>The <code>node:test</code> module facilitates the creation of JavaScript tests.\nTo access it:</p>\n<pre><code class=\"language-mjs\">import test from 'node:test';\n</code></pre>\n<pre><code class=\"language-cjs\">const test = require('node:test');\n</code></pre>\n<p>This module is only available under the <code>node:</code> scheme.</p>\n<p>Tests created via the <code>test</code> module consist of a single function that is\nprocessed in one of three ways:</p>\n<ol>\n<li>A synchronous function that is considered failing if it throws an exception,\nand is considered passing otherwise.</li>\n<li>A function that returns a <code>Promise</code> that is considered failing if the\n<code>Promise</code> rejects, and is considered passing if the <code>Promise</code> fulfills.</li>\n<li>A function that receives a callback function. If the callback receives any\ntruthy value as its first argument, the test is considered failing. If a\nfalsy value is passed as the first argument to the callback, the test is\nconsidered passing. If the test function receives a callback function and\nalso returns a <code>Promise</code>, the test will fail.</li>\n</ol>\n<p>The following example illustrates how tests are written using the\n<code>test</code> module.</p>\n<pre><code class=\"language-js\">test('synchronous passing test', (t) => {\n  // This test passes because it does not throw an exception.\n  assert.strictEqual(1, 1);\n});\n\ntest('synchronous failing test', (t) => {\n  // This test fails because it throws an exception.\n  assert.strictEqual(1, 2);\n});\n\ntest('asynchronous passing test', async (t) => {\n  // This test passes because the Promise returned by the async\n  // function is settled and not rejected.\n  assert.strictEqual(1, 1);\n});\n\ntest('asynchronous failing test', async (t) => {\n  // This test fails because the Promise returned by the async\n  // function is rejected.\n  assert.strictEqual(1, 2);\n});\n\ntest('failing test using Promises', (t) => {\n  // Promises can be used directly as well.\n  return new Promise((resolve, reject) => {\n    setImmediate(() => {\n      reject(new Error('this will cause the test to fail'));\n    });\n  });\n});\n\ntest('callback passing test', (t, done) => {\n  // done() is the callback function. When the setImmediate() runs, it invokes\n  // done() with no arguments.\n  setImmediate(done);\n});\n\ntest('callback failing test', (t, done) => {\n  // When the setImmediate() runs, done() is invoked with an Error object and\n  // the test fails.\n  setImmediate(() => {\n    done(new Error('callback failure'));\n  });\n});\n</code></pre>\n<p>If any tests fail, the process exit code is set to <code>1</code>.</p>",
      "modules": [
        {
          "textRaw": "Subtests",
          "name": "subtests",
          "desc": "<p>The test context's <code>test()</code> method allows subtests to be created.\nIt allows you to structure your tests in a hierarchical manner,\nwhere you can create nested tests within a larger test.\nThis method behaves identically to the top level <code>test()</code> function.\nThe following example demonstrates the creation of a\ntop level test with two subtests.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  await t.test('subtest 1', (t) => {\n    assert.strictEqual(1, 1);\n  });\n\n  await t.test('subtest 2', (t) => {\n    assert.strictEqual(2, 2);\n  });\n});\n</code></pre>\n<blockquote>\n<p><strong>Note:</strong> <code>beforeEach</code> and <code>afterEach</code> hooks are triggered\nbetween each subtest execution.</p>\n</blockquote>\n<p>In this example, <code>await</code> is used to ensure that both subtests have completed.\nThis is necessary because tests do not wait for their subtests to\ncomplete, unlike tests created within suites.\nAny subtests that are still outstanding when their parent finishes\nare cancelled and treated as failures. Any subtest failures cause the parent\ntest to fail.</p>",
          "type": "module",
          "displayName": "Subtests"
        },
        {
          "textRaw": "Skipping tests",
          "name": "skipping_tests",
          "desc": "<p>Individual tests can be skipped by passing the <code>skip</code> option to the test, or by\ncalling the test context's <code>skip()</code> method as shown in the\nfollowing example.</p>\n<pre><code class=\"language-js\">// The skip option is used, but no message is provided.\ntest('skip option', { skip: true }, (t) => {\n  // This code is never executed.\n});\n\n// The skip option is used, and a message is provided.\ntest('skip option with message', { skip: 'this is skipped' }, (t) => {\n  // This code is never executed.\n});\n\ntest('skip() method', (t) => {\n  // Make sure to return here as well if the test contains additional logic.\n  t.skip();\n});\n\ntest('skip() method with message', (t) => {\n  // Make sure to return here as well if the test contains additional logic.\n  t.skip('this is skipped');\n});\n</code></pre>",
          "type": "module",
          "displayName": "Skipping tests"
        },
        {
          "textRaw": "TODO tests",
          "name": "todo_tests",
          "desc": "<p>Individual tests can be marked as flaky or incomplete by passing the <code>todo</code>\noption to the test, or by calling the test context's <code>todo()</code> method, as shown\nin the following example. These tests represent a pending implementation or bug\nthat needs to be fixed. TODO tests are executed, but are not treated as test\nfailures, and therefore do not affect the process exit code. If a test is marked\nas both TODO and skipped, the TODO option is ignored.</p>\n<pre><code class=\"language-js\">// The todo option is used, but no message is provided.\ntest('todo option', { todo: true }, (t) => {\n  // This code is executed, but not treated as a failure.\n  throw new Error('this does not fail the test');\n});\n\n// The todo option is used, and a message is provided.\ntest('todo option with message', { todo: 'this is a todo test' }, (t) => {\n  // This code is executed.\n});\n\ntest('todo() method', (t) => {\n  t.todo();\n});\n\ntest('todo() method with message', (t) => {\n  t.todo('this is a todo test and is not treated as a failure');\n  throw new Error('this does not fail the test');\n});\n</code></pre>",
          "type": "module",
          "displayName": "TODO tests"
        },
        {
          "textRaw": "`describe()` and `it()` aliases",
          "name": "`describe()`_and_`it()`_aliases",
          "desc": "<p>Suites and tests can also be written using the <code>describe()</code> and <code>it()</code>\nfunctions. <a href=\"#describename-options-fn\"><code>describe()</code></a> is an alias for <a href=\"#suitename-options-fn\"><code>suite()</code></a>, and <a href=\"#itname-options-fn\"><code>it()</code></a> is an\nalias for <a href=\"#testname-options-fn\"><code>test()</code></a>.</p>\n<pre><code class=\"language-js\">describe('A thing', () => {\n  it('should work', () => {\n    assert.strictEqual(1, 1);\n  });\n\n  it('should be ok', () => {\n    assert.strictEqual(2, 2);\n  });\n\n  describe('a nested thing', () => {\n    it('should work', () => {\n      assert.strictEqual(3, 3);\n    });\n  });\n});\n</code></pre>\n<p><code>describe()</code> and <code>it()</code> are imported from the <code>node:test</code> module.</p>\n<pre><code class=\"language-mjs\">import { describe, it } from 'node:test';\n</code></pre>\n<pre><code class=\"language-cjs\">const { describe, it } = require('node:test');\n</code></pre>",
          "type": "module",
          "displayName": "`describe()` and `it()` aliases"
        },
        {
          "textRaw": "`only` tests",
          "name": "`only`_tests",
          "desc": "<p>If Node.js is started with the <a href=\"cli.html#--test-only\"><code>--test-only</code></a> command-line option, or test\nisolation is disabled, it is possible to skip all tests except for a selected\nsubset by passing the <code>only</code> option to the tests that should run. When a test\nwith the <code>only</code> option is set, all subtests are also run.\nIf a suite has the <code>only</code> option set, all tests within the suite are run,\nunless it has descendants with the <code>only</code> option set, in which case only those\ntests are run.</p>\n<p>When using <a href=\"#subtests\">subtests</a> within a <code>test()</code>/<code>it()</code>, it is required to mark\nall ancestor tests with the <code>only</code> option to run only a\nselected subset of tests.</p>\n<p>The test context's <code>runOnly()</code>\nmethod can be used to implement the same behavior at the subtest level. Tests\nthat are not executed are omitted from the test runner output.</p>\n<pre><code class=\"language-js\">// Assume Node.js is run with the --test-only command-line option.\n// The suite's 'only' option is set, so these tests are run.\ntest('this test is run', { only: true }, async (t) => {\n  // Within this test, all subtests are run by default.\n  await t.test('running subtest');\n\n  // The test context can be updated to run subtests with the 'only' option.\n  t.runOnly(true);\n  await t.test('this subtest is now skipped');\n  await t.test('this subtest is run', { only: true });\n\n  // Switch the context back to execute all tests.\n  t.runOnly(false);\n  await t.test('this subtest is now run');\n\n  // Explicitly do not run these tests.\n  await t.test('skipped subtest 3', { only: false });\n  await t.test('skipped subtest 4', { skip: true });\n});\n\n// The 'only' option is not set, so this test is skipped.\ntest('this test is not run', () => {\n  // This code is not run.\n  throw new Error('fail');\n});\n\ndescribe('a suite', () => {\n  // The 'only' option is set, so this test is run.\n  it('this test is run', { only: true }, () => {\n    // This code is run.\n  });\n\n  it('this test is not run', () => {\n    // This code is not run.\n    throw new Error('fail');\n  });\n});\n\ndescribe.only('a suite', () => {\n  // The 'only' option is set, so this test is run.\n  it('this test is run', () => {\n    // This code is run.\n  });\n\n  it('this test is run', () => {\n    // This code is run.\n  });\n});\n</code></pre>",
          "type": "module",
          "displayName": "`only` tests"
        },
        {
          "textRaw": "Filtering tests by name",
          "name": "filtering_tests_by_name",
          "desc": "<p>The <a href=\"cli.html#--test-name-pattern\"><code>--test-name-pattern</code></a> command-line option can be used to only run\ntests whose name matches the provided pattern, and the\n<a href=\"cli.html#--test-skip-pattern\"><code>--test-skip-pattern</code></a> option can be used to skip tests whose name\nmatches the provided pattern. Test name patterns are interpreted as\nJavaScript regular expressions. The <code>--test-name-pattern</code> and\n<code>--test-skip-pattern</code> options can be specified multiple times in order to run\nnested tests. For each test that is executed, any corresponding test hooks,\nsuch as <code>beforeEach()</code>, are also run. Tests that are not executed are omitted\nfrom the test runner output.</p>\n<p>Given the following test file, starting Node.js with the\n<code>--test-name-pattern=\"test [1-3]\"</code> option would cause the test runner to execute\n<code>test 1</code>, <code>test 2</code>, and <code>test 3</code>. If <code>test 1</code> did not match the test name\npattern, then its subtests would not execute, despite matching the pattern. The\nsame set of tests could also be executed by passing <code>--test-name-pattern</code>\nmultiple times (e.g. <code>--test-name-pattern=\"test 1\"</code>,\n<code>--test-name-pattern=\"test 2\"</code>, etc.).</p>\n<pre><code class=\"language-js\">test('test 1', async (t) => {\n  await t.test('test 2');\n  await t.test('test 3');\n});\n\ntest('Test 4', async (t) => {\n  await t.test('Test 5');\n  await t.test('test 6');\n});\n</code></pre>\n<p>Test name patterns can also be specified using regular expression literals. This\nallows regular expression flags to be used. In the previous example, starting\nNode.js with <code>--test-name-pattern=\"/test [4-5]/i\"</code> (or <code>--test-skip-pattern=\"/test [4-5]/i\"</code>)\nwould match <code>Test 4</code> and <code>Test 5</code> because the pattern is case-insensitive.</p>\n<p>To match a single test with a pattern, you can prefix it with all its ancestor\ntest names separated by space, to ensure it is unique.\nFor example, given the following test file:</p>\n<pre><code class=\"language-js\">describe('test 1', (t) => {\n  it('some test');\n});\n\ndescribe('test 2', (t) => {\n  it('some test');\n});\n</code></pre>\n<p>Starting Node.js with <code>--test-name-pattern=\"test 1 some test\"</code> would match\nonly <code>some test</code> in <code>test 1</code>.</p>\n<p>Test name patterns do not change the set of files that the test runner executes.</p>\n<p>If both <code>--test-name-pattern</code> and <code>--test-skip-pattern</code> are supplied,\ntests must satisfy <strong>both</strong> requirements in order to be executed.</p>",
          "type": "module",
          "displayName": "Filtering tests by name"
        },
        {
          "textRaw": "Extraneous asynchronous activity",
          "name": "extraneous_asynchronous_activity",
          "desc": "<p>Once a test function finishes executing, the results are reported as quickly\nas possible while maintaining the order of the tests. However, it is possible\nfor the test function to generate asynchronous activity that outlives the test\nitself. The test runner handles this type of activity, but does not delay the\nreporting of test results in order to accommodate it.</p>\n<p>In the following example, a test completes with two <code>setImmediate()</code>\noperations still outstanding. The first <code>setImmediate()</code> attempts to create a\nnew subtest. Because the parent test has already finished and output its\nresults, the new subtest is immediately marked as failed, and reported later\nto the <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<p>The second <code>setImmediate()</code> creates an <code>uncaughtException</code> event.\n<code>uncaughtException</code> and <code>unhandledRejection</code> events originating from a completed\ntest are marked as failed by the <code>test</code> module and reported as diagnostic\nwarnings at the top level by the <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<pre><code class=\"language-js\">test('a test that creates asynchronous activity', (t) => {\n  setImmediate(() => {\n    t.test('subtest that is created too late', (t) => {\n      throw new Error('error1');\n    });\n  });\n\n  setImmediate(() => {\n    throw new Error('error2');\n  });\n\n  // The test finishes after this line.\n});\n</code></pre>",
          "type": "module",
          "displayName": "Extraneous asynchronous activity"
        },
        {
          "textRaw": "Watch mode",
          "name": "watch_mode",
          "meta": {
            "added": [
              "v19.2.0",
              "v18.13.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": "Experimental",
          "desc": "<p>The Node.js test runner supports running in watch mode by passing the <code>--watch</code> flag:</p>\n<pre><code class=\"language-bash\">node --test --watch\n</code></pre>\n<p>In watch mode, the test runner will watch for changes to test files and\ntheir dependencies. When a change is detected, the test runner will\nrerun the tests affected by the change.\nThe test runner will continue to run until the process is terminated.</p>",
          "type": "module",
          "displayName": "Watch mode"
        },
        {
          "textRaw": "Running tests from the command line",
          "name": "running_tests_from_the_command_line",
          "desc": "<p>The Node.js test runner can be invoked from the command line by passing the\n<a href=\"cli.html#--test\"><code>--test</code></a> flag:</p>\n<pre><code class=\"language-bash\">node --test\n</code></pre>\n<p>By default, Node.js will run all files matching these patterns:</p>\n<ul>\n<li><code>**/*.test.{cjs,mjs,js}</code></li>\n<li><code>**/*-test.{cjs,mjs,js}</code></li>\n<li><code>**/*_test.{cjs,mjs,js}</code></li>\n<li><code>**/test-*.{cjs,mjs,js}</code></li>\n<li><code>**/test.{cjs,mjs,js}</code></li>\n<li><code>**/test/**/*.{cjs,mjs,js}</code></li>\n</ul>\n<p>Unless <a href=\"cli.html#--no-experimental-strip-types\"><code>--no-experimental-strip-types</code></a> is supplied, the following\nadditional patterns are also matched:</p>\n<ul>\n<li><code>**/*.test.{cts,mts,ts}</code></li>\n<li><code>**/*-test.{cts,mts,ts}</code></li>\n<li><code>**/*_test.{cts,mts,ts}</code></li>\n<li><code>**/test-*.{cts,mts,ts}</code></li>\n<li><code>**/test.{cts,mts,ts}</code></li>\n<li><code>**/test/**/*.{cts,mts,ts}</code></li>\n</ul>\n<p>Alternatively, one or more glob patterns can be provided as the\nfinal argument(s) to the Node.js command, as shown below.\nGlob patterns follow the behavior of <a href=\"https://man7.org/linux/man-pages/man7/glob.7.html\"><code>glob(7)</code></a>.\nThe glob patterns should be enclosed in double quotes on the command line to\nprevent shell expansion, which can reduce portability across systems.</p>\n<pre><code class=\"language-bash\">node --test \"**/*.test.js\" \"**/*.spec.js\"\n</code></pre>\n<p>Matching files are executed as test files.\nMore information on the test file execution can be found\nin the <a href=\"#test-runner-execution-model\">test runner execution model</a> section.</p>",
          "modules": [
            {
              "textRaw": "Test runner execution model",
              "name": "test_runner_execution_model",
              "desc": "<p>When process-level test isolation is enabled, each matching test file is\nexecuted in a separate child process. The maximum number of child processes\nrunning at any time is controlled by the <a href=\"cli.html#--test-concurrency\"><code>--test-concurrency</code></a> flag. If the\nchild process finishes with an exit code of 0, the test is considered passing.\nOtherwise, the test is considered to be a failure. Test files must be executable\nby Node.js, but are not required to use the <code>node:test</code> module internally.</p>\n<p>Each test file is executed as if it was a regular script. That is, if the test\nfile itself uses <code>node:test</code> to define tests, all of those tests will be\nexecuted within a single application thread, regardless of the value of the\n<code>concurrency</code> option of <a href=\"#testname-options-fn\"><code>test()</code></a>.</p>\n<p>When process-level test isolation is disabled, each matching test file is\nimported into the test runner process. Once all test files have been loaded, the\ntop level tests are executed with a concurrency of one. Because the test files\nare all run within the same context, it is possible for tests to interact with\neach other in ways that are not possible when isolation is enabled. For example,\nif a test relies on global state, it is possible for that state to be modified\nby a test originating from another file.</p>",
              "type": "module",
              "displayName": "Test runner execution model"
            }
          ],
          "type": "module",
          "displayName": "Running tests from the command line"
        },
        {
          "textRaw": "Collecting code coverage",
          "name": "collecting_code_coverage",
          "stability": 1,
          "stabilityText": "Experimental",
          "desc": "<p>When Node.js is started with the <a href=\"cli.html#--experimental-test-coverage\"><code>--experimental-test-coverage</code></a>\ncommand-line flag, code coverage is collected and statistics are reported once\nall tests have completed. If the <a href=\"cli.html#node_v8_coveragedir\"><code>NODE_V8_COVERAGE</code></a> environment variable is\nused to specify a code coverage directory, the generated V8 coverage files are\nwritten to that directory. Node.js core modules and files within\n<code>node_modules/</code> directories are, by default, not included in the coverage report.\nHowever, they can be explicitly included via the <a href=\"cli.html#--test-coverage-include\"><code>--test-coverage-include</code></a> flag.\nBy default all the matching test files are excluded from the coverage report.\nExclusions can be overridden by using the <a href=\"cli.html#--test-coverage-exclude\"><code>--test-coverage-exclude</code></a> flag.\nIf coverage is enabled, the coverage report is sent to any <a href=\"#test-reporters\">test reporters</a> via\nthe <code>'test:coverage'</code> event.</p>\n<p>Coverage can be disabled on a series of lines using the following\ncomment syntax:</p>\n<pre><code class=\"language-js\">/* node:coverage disable */\nif (anAlwaysFalseCondition) {\n  // Code in this branch will never be executed, but the lines are ignored for\n  // coverage purposes. All lines following the 'disable' comment are ignored\n  // until a corresponding 'enable' comment is encountered.\n  console.log('this is never executed');\n}\n/* node:coverage enable */\n</code></pre>\n<p>Coverage can also be disabled for a specified number of lines. After the\nspecified number of lines, coverage will be automatically reenabled. If the\nnumber of lines is not explicitly provided, a single line is ignored.</p>\n<pre><code class=\"language-js\">/* node:coverage ignore next */\nif (anAlwaysFalseCondition) { console.log('this is never executed'); }\n\n/* node:coverage ignore next 3 */\nif (anAlwaysFalseCondition) {\n  console.log('this is never executed');\n}\n</code></pre>",
          "modules": [
            {
              "textRaw": "Coverage reporters",
              "name": "coverage_reporters",
              "desc": "<p>The tap and spec reporters will print a summary of the coverage statistics.\nThere is also an lcov reporter that will generate an lcov file which can be\nused as an in depth coverage report.</p>\n<pre><code class=\"language-bash\">node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info\n</code></pre>\n<ul>\n<li>No test results are reported by this reporter.</li>\n<li>This reporter should ideally be used alongside another reporter.</li>\n</ul>",
              "type": "module",
              "displayName": "Coverage reporters"
            }
          ],
          "type": "module",
          "displayName": "Collecting code coverage"
        },
        {
          "textRaw": "Mocking",
          "name": "mocking",
          "desc": "<p>The <code>node:test</code> module supports mocking during testing via a top-level <code>mock</code>\nobject. The following example creates a spy on a function that adds two numbers\ntogether. The spy is then used to assert that the function was called as\nexpected.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { mock, test } from 'node:test';\n\ntest('spies on a function', () => {\n  const sum = mock.fn((a, b) => {\n    return a + b;\n  });\n\n  assert.strictEqual(sum.mock.callCount(), 0);\n  assert.strictEqual(sum(3, 4), 7);\n  assert.strictEqual(sum.mock.callCount(), 1);\n\n  const call = sum.mock.calls[0];\n  assert.deepStrictEqual(call.arguments, [3, 4]);\n  assert.strictEqual(call.result, 7);\n  assert.strictEqual(call.error, undefined);\n\n  // Reset the globally tracked mocks.\n  mock.reset();\n});\n</code></pre>\n<pre><code class=\"language-cjs\">'use strict';\nconst assert = require('node:assert');\nconst { mock, test } = require('node:test');\n\ntest('spies on a function', () => {\n  const sum = mock.fn((a, b) => {\n    return a + b;\n  });\n\n  assert.strictEqual(sum.mock.callCount(), 0);\n  assert.strictEqual(sum(3, 4), 7);\n  assert.strictEqual(sum.mock.callCount(), 1);\n\n  const call = sum.mock.calls[0];\n  assert.deepStrictEqual(call.arguments, [3, 4]);\n  assert.strictEqual(call.result, 7);\n  assert.strictEqual(call.error, undefined);\n\n  // Reset the globally tracked mocks.\n  mock.reset();\n});\n</code></pre>\n<p>The same mocking functionality is also exposed on the <a href=\"#class-testcontext\"><code>TestContext</code></a> object\nof each test. The following example creates a spy on an object method using the\nAPI exposed on the <code>TestContext</code>. The benefit of mocking via the test context is\nthat the test runner will automatically restore all mocked functionality once\nthe test finishes.</p>\n<pre><code class=\"language-js\">test('spies on an object method', (t) => {\n  const number = {\n    value: 5,\n    add(a) {\n      return this.value + a;\n    },\n  };\n\n  t.mock.method(number, 'add');\n  assert.strictEqual(number.add.mock.callCount(), 0);\n  assert.strictEqual(number.add(3), 8);\n  assert.strictEqual(number.add.mock.callCount(), 1);\n\n  const call = number.add.mock.calls[0];\n\n  assert.deepStrictEqual(call.arguments, [3]);\n  assert.strictEqual(call.result, 8);\n  assert.strictEqual(call.target, undefined);\n  assert.strictEqual(call.this, number);\n});\n</code></pre>",
          "modules": [
            {
              "textRaw": "Timers",
              "name": "timers",
              "desc": "<p>Mocking timers is a technique commonly used in software testing to simulate and\ncontrol the behavior of timers, such as <code>setInterval</code> and <code>setTimeout</code>,\nwithout actually waiting for the specified time intervals.</p>\n<p>Refer to the <a href=\"#class-mocktimers\"><code>MockTimers</code></a> class for a full list of methods and features.</p>\n<p>This allows developers to write more reliable and\npredictable tests for time-dependent functionality.</p>\n<p>The example below shows how to mock <code>setTimeout</code>.\nUsing <code>.enable({ apis: ['setTimeout'] });</code>\nit will mock the <code>setTimeout</code> functions in the <a href=\"./timers.html\">node:timers</a> and\n<a href=\"./timers.html#timers-promises-api\">node:timers/promises</a> modules,\nas well as from the Node.js global context.</p>\n<p><strong>Note:</strong> Destructuring functions such as\n<code>import { setTimeout } from 'node:timers'</code>\nis currently not supported by this API.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { mock, test } from 'node:test';\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', () => {\n  const fn = mock.fn();\n\n  // Optionally choose what to mock\n  mock.timers.enable({ apis: ['setTimeout'] });\n  setTimeout(fn, 9999);\n  assert.strictEqual(fn.mock.callCount(), 0);\n\n  // Advance in time\n  mock.timers.tick(9999);\n  assert.strictEqual(fn.mock.callCount(), 1);\n\n  // Reset the globally tracked mocks.\n  mock.timers.reset();\n\n  // If you call reset mock instance, it will also reset timers instance\n  mock.reset();\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { mock, test } = require('node:test');\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', () => {\n  const fn = mock.fn();\n\n  // Optionally choose what to mock\n  mock.timers.enable({ apis: ['setTimeout'] });\n  setTimeout(fn, 9999);\n  assert.strictEqual(fn.mock.callCount(), 0);\n\n  // Advance in time\n  mock.timers.tick(9999);\n  assert.strictEqual(fn.mock.callCount(), 1);\n\n  // Reset the globally tracked mocks.\n  mock.timers.reset();\n\n  // If you call reset mock instance, it will also reset timers instance\n  mock.reset();\n});\n</code></pre>\n<p>The same mocking functionality is also exposed in the mock property on the <a href=\"#class-testcontext\"><code>TestContext</code></a> object\nof each test. The benefit of mocking via the test context is\nthat the test runner will automatically restore all mocked timers\nfunctionality once the test finishes.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  setTimeout(fn, 9999);\n  assert.strictEqual(fn.mock.callCount(), 0);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n  assert.strictEqual(fn.mock.callCount(), 1);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  setTimeout(fn, 9999);\n  assert.strictEqual(fn.mock.callCount(), 0);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n  assert.strictEqual(fn.mock.callCount(), 1);\n});\n</code></pre>",
              "type": "module",
              "displayName": "Timers"
            },
            {
              "textRaw": "Dates",
              "name": "dates",
              "desc": "<p>The mock timers API also allows the mocking of the <code>Date</code> object. This is a\nuseful feature for testing time-dependent functionality, or to simulate\ninternal calendar functions such as <code>Date.now()</code>.</p>\n<p>The dates implementation is also part of the <a href=\"#class-mocktimers\"><code>MockTimers</code></a> class. Refer to it\nfor a full list of methods and features.</p>\n<p><strong>Note:</strong> Dates and timers are dependent when mocked together. This means that\nif you have both the <code>Date</code> and <code>setTimeout</code> mocked, advancing the time will\nalso advance the mocked date as they simulate a single internal clock.</p>\n<p>The example below show how to mock the <code>Date</code> object and obtain the current\n<code>Date.now()</code> value.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('mocks the Date object', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['Date'] });\n  // If not specified, the initial date will be based on 0 in the UNIX epoch\n  assert.strictEqual(Date.now(), 0);\n\n  // Advance in time will also advance the date\n  context.mock.timers.tick(9999);\n  assert.strictEqual(Date.now(), 9999);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('mocks the Date object', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['Date'] });\n  // If not specified, the initial date will be based on 0 in the UNIX epoch\n  assert.strictEqual(Date.now(), 0);\n\n  // Advance in time will also advance the date\n  context.mock.timers.tick(9999);\n  assert.strictEqual(Date.now(), 9999);\n});\n</code></pre>\n<p>If there is no initial epoch set, the initial date will be based on 0 in the\nUnix epoch. This is January 1st, 1970, 00:00:00 UTC. You can set an initial date\nby passing a <code>now</code> property to the <code>.enable()</code> method. This value will be used\nas the initial date for the mocked <code>Date</code> object. It can either be a positive\ninteger, or another Date object.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('mocks the Date object with initial time', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['Date'], now: 100 });\n  assert.strictEqual(Date.now(), 100);\n\n  // Advance in time will also advance the date\n  context.mock.timers.tick(200);\n  assert.strictEqual(Date.now(), 300);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('mocks the Date object with initial time', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['Date'], now: 100 });\n  assert.strictEqual(Date.now(), 100);\n\n  // Advance in time will also advance the date\n  context.mock.timers.tick(200);\n  assert.strictEqual(Date.now(), 300);\n});\n</code></pre>\n<p>You can use the <code>.setTime()</code> method to manually move the mocked date to another\ntime. This method only accepts a positive integer.</p>\n<p><strong>Note:</strong> This method will execute any mocked timers that are in the past\nfrom the new time.</p>\n<p>In the below example we are setting a new time for the mocked date.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('sets the time of a date object', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['Date'], now: 100 });\n  assert.strictEqual(Date.now(), 100);\n\n  // Advance in time will also advance the date\n  context.mock.timers.setTime(1000);\n  context.mock.timers.tick(200);\n  assert.strictEqual(Date.now(), 1200);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('sets the time of a date object', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['Date'], now: 100 });\n  assert.strictEqual(Date.now(), 100);\n\n  // Advance in time will also advance the date\n  context.mock.timers.setTime(1000);\n  context.mock.timers.tick(200);\n  assert.strictEqual(Date.now(), 1200);\n});\n</code></pre>\n<p>If you have any timer that's set to run in the past, it will be executed as if\nthe <code>.tick()</code> method has been called. This is useful if you want to test\ntime-dependent functionality that's already in the past.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('runs timers as setTime passes ticks', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const fn = context.mock.fn();\n  setTimeout(fn, 1000);\n\n  context.mock.timers.setTime(800);\n  // Timer is not executed as the time is not yet reached\n  assert.strictEqual(fn.mock.callCount(), 0);\n  assert.strictEqual(Date.now(), 800);\n\n  context.mock.timers.setTime(1200);\n  // Timer is executed as the time is now reached\n  assert.strictEqual(fn.mock.callCount(), 1);\n  assert.strictEqual(Date.now(), 1200);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('runs timers as setTime passes ticks', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const fn = context.mock.fn();\n  setTimeout(fn, 1000);\n\n  context.mock.timers.setTime(800);\n  // Timer is not executed as the time is not yet reached\n  assert.strictEqual(fn.mock.callCount(), 0);\n  assert.strictEqual(Date.now(), 800);\n\n  context.mock.timers.setTime(1200);\n  // Timer is executed as the time is now reached\n  assert.strictEqual(fn.mock.callCount(), 1);\n  assert.strictEqual(Date.now(), 1200);\n});\n</code></pre>\n<p>Using <code>.runAll()</code> will execute all timers that are currently in the queue. This\nwill also advance the mocked date to the time of the last timer that was\nexecuted as if the time has passed.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('runs timers as setTime passes ticks', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const fn = context.mock.fn();\n  setTimeout(fn, 1000);\n  setTimeout(fn, 2000);\n  setTimeout(fn, 3000);\n\n  context.mock.timers.runAll();\n  // All timers are executed as the time is now reached\n  assert.strictEqual(fn.mock.callCount(), 3);\n  assert.strictEqual(Date.now(), 3000);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('runs timers as setTime passes ticks', (context) => {\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const fn = context.mock.fn();\n  setTimeout(fn, 1000);\n  setTimeout(fn, 2000);\n  setTimeout(fn, 3000);\n\n  context.mock.timers.runAll();\n  // All timers are executed as the time is now reached\n  assert.strictEqual(fn.mock.callCount(), 3);\n  assert.strictEqual(Date.now(), 3000);\n});\n</code></pre>",
              "type": "module",
              "displayName": "Dates"
            }
          ],
          "type": "module",
          "displayName": "Mocking"
        },
        {
          "textRaw": "Snapshot testing",
          "name": "snapshot_testing",
          "meta": {
            "added": [
              "v22.3.0"
            ],
            "changes": [
              {
                "version": "v23.4.0",
                "pr-url": "https://github.com/nodejs/node/pull/55897",
                "description": "Snapsnot testing is no longer experimental."
              }
            ]
          },
          "desc": "<p>Snapshot tests allow arbitrary values to be serialized into string values and\ncompared against a set of known good values. The known good values are known as\nsnapshots, and are stored in a snapshot file. Snapshot files are managed by the\ntest runner, but are designed to be human readable to aid in debugging. Best\npractice is for snapshot files to be checked into source control along with your\ntest files.</p>\n<p>Snapshot files are generated by starting Node.js with the\n<a href=\"cli.html#--test-update-snapshots\"><code>--test-update-snapshots</code></a> command-line flag. A separate snapshot file is\ngenerated for each test file. By default, the snapshot file has the same name\nas the test file with a <code>.snapshot</code> file extension. This behavior can be\nconfigured using the <code>snapshot.setResolveSnapshotPath()</code> function. Each\nsnapshot assertion corresponds to an export in the snapshot file.</p>\n<p>An example snapshot test is shown below. The first time this test is executed,\nit will fail because the corresponding snapshot file does not exist.</p>\n<pre><code class=\"language-js\">// test.js\nsuite('suite of snapshot tests', () => {\n  test('snapshot test', (t) => {\n    t.assert.snapshot({ value1: 1, value2: 2 });\n    t.assert.snapshot(5);\n  });\n});\n</code></pre>\n<p>Generate the snapshot file by running the test file with\n<code>--test-update-snapshots</code>. The test should pass, and a file named\n<code>test.js.snapshot</code> is created in the same directory as the test file. The\ncontents of the snapshot file are shown below. Each snapshot is identified by\nthe full name of test and a counter to differentiate between snapshots in the\nsame test.</p>\n<pre><code class=\"language-js\">exports[`suite of snapshot tests > snapshot test 1`] = `\n{\n  \"value1\": 1,\n  \"value2\": 2\n}\n`;\n\nexports[`suite of snapshot tests > snapshot test 2`] = `\n5\n`;\n</code></pre>\n<p>Once the snapshot file is created, run the tests again without the\n<code>--test-update-snapshots</code> flag. The tests should pass now.</p>",
          "type": "module",
          "displayName": "Snapshot testing"
        },
        {
          "textRaw": "Test reporters",
          "name": "test_reporters",
          "meta": {
            "added": [
              "v19.6.0",
              "v18.15.0"
            ],
            "changes": [
              {
                "version": [
                  "v19.9.0",
                  "v18.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/47238",
                "description": "Reporters are now exposed at `node:test/reporters`."
              }
            ]
          },
          "desc": "<p>The <code>node:test</code> module supports passing <a href=\"cli.html#--test-reporter\"><code>--test-reporter</code></a>\nflags for the test runner to use a specific reporter.</p>\n<p>The following built-reporters are supported:</p>\n<ul>\n<li>\n<p><code>spec</code>\nThe <code>spec</code> reporter outputs the test results in a human-readable format. This\nis the default reporter.</p>\n</li>\n<li>\n<p><code>tap</code>\nThe <code>tap</code> reporter outputs the test results in the <a href=\"https://testanything.org/\">TAP</a> format.</p>\n</li>\n<li>\n<p><code>dot</code>\nThe <code>dot</code> reporter outputs the test results in a compact format,\nwhere each passing test is represented by a <code>.</code>,\nand each failing test is represented by a <code>X</code>.</p>\n</li>\n<li>\n<p><code>junit</code>\nThe junit reporter outputs test results in a jUnit XML format</p>\n</li>\n<li>\n<p><code>lcov</code>\nThe <code>lcov</code> reporter outputs test coverage when used with the\n<a href=\"cli.html#--experimental-test-coverage\"><code>--experimental-test-coverage</code></a> flag.</p>\n</li>\n</ul>\n<p>The exact output of these reporters is subject to change between versions of\nNode.js, and should not be relied on programmatically. If programmatic access\nto the test runner's output is required, use the events emitted by the\n<a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<p>The reporters are available via the <code>node:test/reporters</code> module:</p>\n<pre><code class=\"language-mjs\">import { tap, spec, dot, junit, lcov } from 'node:test/reporters';\n</code></pre>\n<pre><code class=\"language-cjs\">const { tap, spec, dot, junit, lcov } = require('node:test/reporters');\n</code></pre>",
          "modules": [
            {
              "textRaw": "Custom reporters",
              "name": "custom_reporters",
              "desc": "<p><a href=\"cli.html#--test-reporter\"><code>--test-reporter</code></a> can be used to specify a path to custom reporter.\nA custom reporter is a module that exports a value\naccepted by <a href=\"stream.html#streamcomposestreams\">stream.compose</a>.\nReporters should transform events emitted by a <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a></p>\n<p>Example of a custom reporter using <a href=\"stream.html#class-streamtransform\" class=\"type\">&lt;stream.Transform&gt;</a>:</p>\n<pre><code class=\"language-mjs\">import { Transform } from 'node:stream';\n\nconst customReporter = new Transform({\n  writableObjectMode: true,\n  transform(event, encoding, callback) {\n    switch (event.type) {\n      case 'test:dequeue':\n        callback(null, `test ${event.data.name} dequeued`);\n        break;\n      case 'test:enqueue':\n        callback(null, `test ${event.data.name} enqueued`);\n        break;\n      case 'test:watch:drained':\n        callback(null, 'test watch queue drained');\n        break;\n      case 'test:start':\n        callback(null, `test ${event.data.name} started`);\n        break;\n      case 'test:pass':\n        callback(null, `test ${event.data.name} passed`);\n        break;\n      case 'test:fail':\n        callback(null, `test ${event.data.name} failed`);\n        break;\n      case 'test:plan':\n        callback(null, 'test plan');\n        break;\n      case 'test:diagnostic':\n      case 'test:stderr':\n      case 'test:stdout':\n        callback(null, event.data.message);\n        break;\n      case 'test:coverage': {\n        const { totalLineCount } = event.data.summary.totals;\n        callback(null, `total line count: ${totalLineCount}\\n`);\n        break;\n      }\n    }\n  },\n});\n\nexport default customReporter;\n</code></pre>\n<pre><code class=\"language-cjs\">const { Transform } = require('node:stream');\n\nconst customReporter = new Transform({\n  writableObjectMode: true,\n  transform(event, encoding, callback) {\n    switch (event.type) {\n      case 'test:dequeue':\n        callback(null, `test ${event.data.name} dequeued`);\n        break;\n      case 'test:enqueue':\n        callback(null, `test ${event.data.name} enqueued`);\n        break;\n      case 'test:watch:drained':\n        callback(null, 'test watch queue drained');\n        break;\n      case 'test:start':\n        callback(null, `test ${event.data.name} started`);\n        break;\n      case 'test:pass':\n        callback(null, `test ${event.data.name} passed`);\n        break;\n      case 'test:fail':\n        callback(null, `test ${event.data.name} failed`);\n        break;\n      case 'test:plan':\n        callback(null, 'test plan');\n        break;\n      case 'test:diagnostic':\n      case 'test:stderr':\n      case 'test:stdout':\n        callback(null, event.data.message);\n        break;\n      case 'test:coverage': {\n        const { totalLineCount } = event.data.summary.totals;\n        callback(null, `total line count: ${totalLineCount}\\n`);\n        break;\n      }\n    }\n  },\n});\n\nmodule.exports = customReporter;\n</code></pre>\n<p>Example of a custom reporter using a generator function:</p>\n<pre><code class=\"language-mjs\">export default async function * customReporter(source) {\n  for await (const event of source) {\n    switch (event.type) {\n      case 'test:dequeue':\n        yield `test ${event.data.name} dequeued\\n`;\n        break;\n      case 'test:enqueue':\n        yield `test ${event.data.name} enqueued\\n`;\n        break;\n      case 'test:watch:drained':\n        yield 'test watch queue drained\\n';\n        break;\n      case 'test:start':\n        yield `test ${event.data.name} started\\n`;\n        break;\n      case 'test:pass':\n        yield `test ${event.data.name} passed\\n`;\n        break;\n      case 'test:fail':\n        yield `test ${event.data.name} failed\\n`;\n        break;\n      case 'test:plan':\n        yield 'test plan\\n';\n        break;\n      case 'test:diagnostic':\n      case 'test:stderr':\n      case 'test:stdout':\n        yield `${event.data.message}\\n`;\n        break;\n      case 'test:coverage': {\n        const { totalLineCount } = event.data.summary.totals;\n        yield `total line count: ${totalLineCount}\\n`;\n        break;\n      }\n    }\n  }\n}\n</code></pre>\n<pre><code class=\"language-cjs\">module.exports = async function * customReporter(source) {\n  for await (const event of source) {\n    switch (event.type) {\n      case 'test:dequeue':\n        yield `test ${event.data.name} dequeued\\n`;\n        break;\n      case 'test:enqueue':\n        yield `test ${event.data.name} enqueued\\n`;\n        break;\n      case 'test:watch:drained':\n        yield 'test watch queue drained\\n';\n        break;\n      case 'test:start':\n        yield `test ${event.data.name} started\\n`;\n        break;\n      case 'test:pass':\n        yield `test ${event.data.name} passed\\n`;\n        break;\n      case 'test:fail':\n        yield `test ${event.data.name} failed\\n`;\n        break;\n      case 'test:plan':\n        yield 'test plan\\n';\n        break;\n      case 'test:diagnostic':\n      case 'test:stderr':\n      case 'test:stdout':\n        yield `${event.data.message}\\n`;\n        break;\n      case 'test:coverage': {\n        const { totalLineCount } = event.data.summary.totals;\n        yield `total line count: ${totalLineCount}\\n`;\n        break;\n      }\n    }\n  }\n};\n</code></pre>\n<p>The value provided to <code>--test-reporter</code> should be a string like one used in an\n<code>import()</code> in JavaScript code, or a value provided for <a href=\"cli.html#--importmodule\"><code>--import</code></a>.</p>",
              "type": "module",
              "displayName": "Custom reporters"
            },
            {
              "textRaw": "Multiple reporters",
              "name": "multiple_reporters",
              "desc": "<p>The <a href=\"cli.html#--test-reporter\"><code>--test-reporter</code></a> flag can be specified multiple times to report test\nresults in several formats. In this situation\nit is required to specify a destination for each reporter\nusing <a href=\"cli.html#--test-reporter-destination\"><code>--test-reporter-destination</code></a>.\nDestination can be <code>stdout</code>, <code>stderr</code>, or a file path.\nReporters and destinations are paired according\nto the order they were specified.</p>\n<p>In the following example, the <code>spec</code> reporter will output to <code>stdout</code>,\nand the <code>dot</code> reporter will output to <code>file.txt</code>:</p>\n<pre><code class=\"language-bash\">node --test-reporter=spec --test-reporter=dot --test-reporter-destination=stdout --test-reporter-destination=file.txt\n</code></pre>\n<p>When a single reporter is specified, the destination will default to <code>stdout</code>,\nunless a destination is explicitly provided.</p>",
              "type": "module",
              "displayName": "Multiple reporters"
            }
          ],
          "type": "module",
          "displayName": "Test reporters"
        },
        {
          "textRaw": "`assert`",
          "name": "`assert`",
          "meta": {
            "added": [
              "v23.7.0"
            ],
            "changes": []
          },
          "desc": "<p>An object whose methods are used to configure available assertions on the\n<code>TestContext</code> objects in the current process. The methods from <code>node:assert</code>\nand snapshot testing functions are available by default.</p>\n<p>It is possible to apply the same configuration to all files by placing common\nconfiguration code in a module\npreloaded with <code>--require</code> or <code>--import</code>.</p>",
          "methods": [
            {
              "textRaw": "`assert.register(name, fn)`",
              "type": "method",
              "name": "register",
              "meta": {
                "added": [
                  "v23.7.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Defines a new assertion function with the provided name and function. If an\nassertion already exists with the same name, it is overwritten.</p>"
            }
          ],
          "type": "module",
          "displayName": "`assert`"
        },
        {
          "textRaw": "`snapshot`",
          "name": "`snapshot`",
          "meta": {
            "added": [
              "v22.3.0"
            ],
            "changes": []
          },
          "desc": "<p>An object whose methods are used to configure default snapshot settings in the\ncurrent process. It is possible to apply the same configuration to all files by\nplacing common configuration code in a module preloaded with <code>--require</code> or\n<code>--import</code>.</p>",
          "methods": [
            {
              "textRaw": "`snapshot.setDefaultSnapshotSerializers(serializers)`",
              "type": "method",
              "name": "setDefaultSnapshotSerializers",
              "meta": {
                "added": [
                  "v22.3.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`serializers` {Array} An array of synchronous functions used as the default serializers for snapshot tests.",
                      "name": "serializers",
                      "type": "Array",
                      "desc": "An array of synchronous functions used as the default serializers for snapshot tests."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to customize the default serialization mechanism used by\nthe test runner. By default, the test runner performs serialization by calling\n<code>JSON.stringify(value, null, 2)</code> on the provided value. <code>JSON.stringify()</code> does\nhave limitations regarding circular structures and supported data types. If a\nmore robust serialization mechanism is required, this function should be used.</p>"
            },
            {
              "textRaw": "`snapshot.setResolveSnapshotPath(fn)`",
              "type": "method",
              "name": "setResolveSnapshotPath",
              "meta": {
                "added": [
                  "v22.3.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function} A function used to compute the location of the snapshot file. The function receives the path of the test file as its only argument. If the test is not associated with a file (for example in the REPL), the input is undefined. `fn()` must return a string specifying the location of the snapshot snapshot file.",
                      "name": "fn",
                      "type": "Function",
                      "desc": "A function used to compute the location of the snapshot file. The function receives the path of the test file as its only argument. If the test is not associated with a file (for example in the REPL), the input is undefined. `fn()` must return a string specifying the location of the snapshot snapshot file."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to customize the location of the snapshot file used for\nsnapshot testing. By default, the snapshot filename is the same as the entry\npoint filename with a <code>.snapshot</code> file extension.</p>"
            }
          ],
          "type": "module",
          "displayName": "`snapshot`"
        }
      ],
      "methods": [
        {
          "textRaw": "`run([options])`",
          "type": "method",
          "name": "run",
          "meta": {
            "added": [
              "v18.9.0",
              "v16.19.0"
            ],
            "changes": [
              {
                "version": "v23.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/54705",
                "description": "Added the `cwd` option."
              },
              {
                "version": "v23.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/53937",
                "description": "Added coverage options."
              },
              {
                "version": "v22.8.0",
                "pr-url": "https://github.com/nodejs/node/pull/53927",
                "description": "Added the `isolation` option."
              },
              {
                "version": "v22.6.0",
                "pr-url": "https://github.com/nodejs/node/pull/53866",
                "description": "Added the `globPatterns` option."
              },
              {
                "version": [
                  "v22.0.0",
                  "v20.14.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/52038",
                "description": "Added the `forceExit` option."
              },
              {
                "version": [
                  "v20.1.0",
                  "v18.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/47628",
                "description": "Add a testNamePatterns option."
              }
            ]
          },
          "signatures": [
            {
              "return": {
                "textRaw": "Returns: {TestsStream}",
                "name": "return",
                "type": "TestsStream"
              },
              "params": [
                {
                  "textRaw": "`options` {Object} Configuration options for running tests. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for running tests. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`concurrency` {number|boolean} If a number is provided, then that many test processes would run in parallel, where each process corresponds to one test file. If `true`, it would run `os.availableParallelism() - 1` test files in parallel. If `false`, it would only run one test file at a time. **Default:** `false`.",
                      "name": "concurrency",
                      "type": "number|boolean",
                      "default": "`false`",
                      "desc": "If a number is provided, then that many test processes would run in parallel, where each process corresponds to one test file. If `true`, it would run `os.availableParallelism() - 1` test files in parallel. If `false`, it would only run one test file at a time."
                    },
                    {
                      "textRaw": "`cwd`: {string} Specifies the current working directory to be used by the test runner. Serves as the base path for resolving files according to the [test runner execution model][]. **Default:** `process.cwd()`.",
                      "name": "cwd",
                      "type": "string",
                      "default": "`process.cwd()`",
                      "desc": "Specifies the current working directory to be used by the test runner. Serves as the base path for resolving files according to the [test runner execution model][]."
                    },
                    {
                      "textRaw": "`files`: {Array} An array containing the list of files to run. **Default:** matching files from [test runner execution model][].",
                      "name": "files",
                      "type": "Array",
                      "default": "matching files from [test runner execution model][]",
                      "desc": "An array containing the list of files to run."
                    },
                    {
                      "textRaw": "`forceExit`: {boolean} Configures the test runner to exit the process once all known tests have finished executing even if the event loop would otherwise remain active. **Default:** `false`.",
                      "name": "forceExit",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Configures the test runner to exit the process once all known tests have finished executing even if the event loop would otherwise remain active."
                    },
                    {
                      "textRaw": "`globPatterns`: {Array} An array containing the list of glob patterns to match test files. This option cannot be used together with `files`. **Default:** matching files from [test runner execution model][].",
                      "name": "globPatterns",
                      "type": "Array",
                      "default": "matching files from [test runner execution model][]",
                      "desc": "An array containing the list of glob patterns to match test files. This option cannot be used together with `files`."
                    },
                    {
                      "textRaw": "`inspectPort` {number|Function} Sets inspector port of test child process. This can be a number, or a function that takes no arguments and returns a number. If a nullish value is provided, each process gets its own port, incremented from the primary's `process.debugPort`. This option is ignored if the `isolation` option is set to `'none'` as no child processes are spawned. **Default:** `undefined`.",
                      "name": "inspectPort",
                      "type": "number|Function",
                      "default": "`undefined`",
                      "desc": "Sets inspector port of test child process. This can be a number, or a function that takes no arguments and returns a number. If a nullish value is provided, each process gets its own port, incremented from the primary's `process.debugPort`. This option is ignored if the `isolation` option is set to `'none'` as no child processes are spawned."
                    },
                    {
                      "textRaw": "`isolation` {string} Configures the type of test isolation. If set to `'process'`, each test file is run in a separate child process. If set to `'none'`, all test files run in the current process. **Default:** `'process'`.",
                      "name": "isolation",
                      "type": "string",
                      "default": "`'process'`",
                      "desc": "Configures the type of test isolation. If set to `'process'`, each test file is run in a separate child process. If set to `'none'`, all test files run in the current process."
                    },
                    {
                      "textRaw": "`only`: {boolean} If truthy, the test context will only run tests that have the `only` option set",
                      "name": "only",
                      "type": "boolean",
                      "desc": "If truthy, the test context will only run tests that have the `only` option set"
                    },
                    {
                      "textRaw": "`setup` {Function} A function that accepts the `TestsStream` instance and can be used to setup listeners before any tests are run. **Default:** `undefined`.",
                      "name": "setup",
                      "type": "Function",
                      "default": "`undefined`",
                      "desc": "A function that accepts the `TestsStream` instance and can be used to setup listeners before any tests are run."
                    },
                    {
                      "textRaw": "`execArgv` {Array} An array of CLI flags to pass to the `node` executable when spawning the subprocesses. This option has no effect when `isolation` is `'none`'. **Default:** `[]`",
                      "name": "execArgv",
                      "type": "Array",
                      "default": "`[]`",
                      "desc": "An array of CLI flags to pass to the `node` executable when spawning the subprocesses. This option has no effect when `isolation` is `'none`'."
                    },
                    {
                      "textRaw": "`argv` {Array} An array of CLI flags to pass to each test file when spawning the subprocesses. This option has no effect when `isolation` is `'none'`. **Default:** `[]`.",
                      "name": "argv",
                      "type": "Array",
                      "default": "`[]`",
                      "desc": "An array of CLI flags to pass to each test file when spawning the subprocesses. This option has no effect when `isolation` is `'none'`."
                    },
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress test execution.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress test execution."
                    },
                    {
                      "textRaw": "`testNamePatterns` {string|RegExp|Array} A String, RegExp or a RegExp Array, that can be used to only run tests whose name matches the provided pattern. Test name patterns are interpreted as JavaScript regular expressions. For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run. **Default:** `undefined`.",
                      "name": "testNamePatterns",
                      "type": "string|RegExp|Array",
                      "default": "`undefined`",
                      "desc": "A String, RegExp or a RegExp Array, that can be used to only run tests whose name matches the provided pattern. Test name patterns are interpreted as JavaScript regular expressions. For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run."
                    },
                    {
                      "textRaw": "`testSkipPatterns` {string|RegExp|Array} A String, RegExp or a RegExp Array, that can be used to exclude running tests whose name matches the provided pattern. Test name patterns are interpreted as JavaScript regular expressions. For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run. **Default:** `undefined`.",
                      "name": "testSkipPatterns",
                      "type": "string|RegExp|Array",
                      "default": "`undefined`",
                      "desc": "A String, RegExp or a RegExp Array, that can be used to exclude running tests whose name matches the provided pattern. Test name patterns are interpreted as JavaScript regular expressions. For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the test execution will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the test execution will fail after. If unspecified, subtests inherit this value from their parent."
                    },
                    {
                      "textRaw": "`watch` {boolean} Whether to run in watch mode or not. **Default:** `false`.",
                      "name": "watch",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Whether to run in watch mode or not."
                    },
                    {
                      "textRaw": "`shard` {Object} Running tests in a specific shard. **Default:** `undefined`.",
                      "name": "shard",
                      "type": "Object",
                      "default": "`undefined`",
                      "desc": "Running tests in a specific shard.",
                      "options": [
                        {
                          "textRaw": "`index` {number} is a positive integer between 1 and `<total>` that specifies the index of the shard to run. This option is _required_.",
                          "name": "index",
                          "type": "number",
                          "desc": "is a positive integer between 1 and `<total>` that specifies the index of the shard to run. This option is _required_."
                        },
                        {
                          "textRaw": "`total` {number} is a positive integer that specifies the total number of shards to split the test files to. This option is _required_.",
                          "name": "total",
                          "type": "number",
                          "desc": "is a positive integer that specifies the total number of shards to split the test files to. This option is _required_."
                        }
                      ]
                    },
                    {
                      "textRaw": "`coverage` {boolean} enable [code coverage][] collection. **Default:** `false`.",
                      "name": "coverage",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "enable [code coverage][] collection."
                    },
                    {
                      "textRaw": "`coverageExcludeGlobs` {string|Array} Excludes specific files from code coverage using a glob pattern, which can match both absolute and relative file paths. This property is only applicable when `coverage` was set to `true`. If both `coverageExcludeGlobs` and `coverageIncludeGlobs` are provided, files must meet **both** criteria to be included in the coverage report. **Default:** `undefined`.",
                      "name": "coverageExcludeGlobs",
                      "type": "string|Array",
                      "default": "`undefined`",
                      "desc": "Excludes specific files from code coverage using a glob pattern, which can match both absolute and relative file paths. This property is only applicable when `coverage` was set to `true`. If both `coverageExcludeGlobs` and `coverageIncludeGlobs` are provided, files must meet **both** criteria to be included in the coverage report."
                    },
                    {
                      "textRaw": "`coverageIncludeGlobs` {string|Array} Includes specific files in code coverage using a glob pattern, which can match both absolute and relative file paths. This property is only applicable when `coverage` was set to `true`. If both `coverageExcludeGlobs` and `coverageIncludeGlobs` are provided, files must meet **both** criteria to be included in the coverage report. **Default:** `undefined`.",
                      "name": "coverageIncludeGlobs",
                      "type": "string|Array",
                      "default": "`undefined`",
                      "desc": "Includes specific files in code coverage using a glob pattern, which can match both absolute and relative file paths. This property is only applicable when `coverage` was set to `true`. If both `coverageExcludeGlobs` and `coverageIncludeGlobs` are provided, files must meet **both** criteria to be included in the coverage report."
                    },
                    {
                      "textRaw": "`lineCoverage` {number} Require a minimum percent of covered lines. If code coverage does not reach the threshold specified, the process will exit with code `1`. **Default:** `0`.",
                      "name": "lineCoverage",
                      "type": "number",
                      "default": "`0`",
                      "desc": "Require a minimum percent of covered lines. If code coverage does not reach the threshold specified, the process will exit with code `1`."
                    },
                    {
                      "textRaw": "`branchCoverage` {number} Require a minimum percent of covered branches. If code coverage does not reach the threshold specified, the process will exit with code `1`. **Default:** `0`.",
                      "name": "branchCoverage",
                      "type": "number",
                      "default": "`0`",
                      "desc": "Require a minimum percent of covered branches. If code coverage does not reach the threshold specified, the process will exit with code `1`."
                    },
                    {
                      "textRaw": "`functionCoverage` {number} Require a minimum percent of covered functions. If code coverage does not reach the threshold specified, the process will exit with code `1`. **Default:** `0`.",
                      "name": "functionCoverage",
                      "type": "number",
                      "default": "`0`",
                      "desc": "Require a minimum percent of covered functions. If code coverage does not reach the threshold specified, the process will exit with code `1`."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p><strong>Note:</strong> <code>shard</code> is used to horizontally parallelize test running across\nmachines or processes, ideal for large-scale executions across varied\nenvironments. It's incompatible with <code>watch</code> mode, tailored for rapid\ncode iteration by automatically rerunning tests on file changes.</p>\n<pre><code class=\"language-mjs\">import { tap } from 'node:test/reporters';\nimport { run } from 'node:test';\nimport process from 'node:process';\nimport path from 'node:path';\n\nrun({ files: [path.resolve('./tests/test.js')] })\n .on('test:fail', () => {\n   process.exitCode = 1;\n })\n .compose(tap)\n .pipe(process.stdout);\n</code></pre>\n<pre><code class=\"language-cjs\">const { tap } = require('node:test/reporters');\nconst { run } = require('node:test');\nconst path = require('node:path');\n\nrun({ files: [path.resolve('./tests/test.js')] })\n .on('test:fail', () => {\n   process.exitCode = 1;\n })\n .compose(tap)\n .pipe(process.stdout);\n</code></pre>"
        },
        {
          "textRaw": "`suite([name][, options][, fn])`",
          "type": "method",
          "name": "suite",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "return": {
                "textRaw": "Returns: {Promise} Immediately fulfilled with `undefined`.",
                "name": "return",
                "type": "Promise",
                "desc": "Immediately fulfilled with `undefined`."
              },
              "params": [
                {
                  "textRaw": "`name` {string} The name of the suite, which is displayed when reporting test results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.",
                  "name": "name",
                  "type": "string",
                  "default": "The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name",
                  "desc": "The name of the suite, which is displayed when reporting test results."
                },
                {
                  "textRaw": "`options` {Object} Optional configuration options for the suite. This supports the same options as `test([name][, options][, fn])`.",
                  "name": "options",
                  "type": "Object",
                  "desc": "Optional configuration options for the suite. This supports the same options as `test([name][, options][, fn])`."
                },
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The suite function declaring nested tests and suites. The first argument to this function is a [`SuiteContext`][] object. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The suite function declaring nested tests and suites. The first argument to this function is a [`SuiteContext`][] object."
                }
              ]
            }
          ],
          "desc": "<p>The <code>suite()</code> function is imported from the <code>node:test</code> module.</p>"
        },
        {
          "textRaw": "`suite.skip([name][, options][, fn])`",
          "type": "method",
          "name": "skip",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for skipping a suite. This is the same as\n<a href=\"#suitename-options-fn\"><code>suite([name], { skip: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`suite.todo([name][, options][, fn])`",
          "type": "method",
          "name": "todo",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a suite as <code>TODO</code>. This is the same as\n<a href=\"#suitename-options-fn\"><code>suite([name], { todo: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`suite.only([name][, options][, fn])`",
          "type": "method",
          "name": "only",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a suite as <code>only</code>. This is the same as\n<a href=\"#suitename-options-fn\"><code>suite([name], { only: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`test([name][, options][, fn])`",
          "type": "method",
          "name": "test",
          "meta": {
            "added": [
              "v18.0.0",
              "v16.17.0"
            ],
            "changes": [
              {
                "version": [
                  "v20.2.0",
                  "v18.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/47909",
                "description": "Added the `skip`, `todo`, and `only` shorthands."
              },
              {
                "version": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/43554",
                "description": "Add a `signal` option."
              },
              {
                "version": [
                  "v18.7.0",
                  "v16.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/43505",
                "description": "Add a `timeout` option."
              }
            ]
          },
          "signatures": [
            {
              "return": {
                "textRaw": "Returns: {Promise} Fulfilled with `undefined` once the test completes, or immediately if the test runs within a suite.",
                "name": "return",
                "type": "Promise",
                "desc": "Fulfilled with `undefined` once the test completes, or immediately if the test runs within a suite."
              },
              "params": [
                {
                  "textRaw": "`name` {string} The name of the test, which is displayed when reporting test results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.",
                  "name": "name",
                  "type": "string",
                  "default": "The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name",
                  "desc": "The name of the test, which is displayed when reporting test results."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the test. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the test. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`concurrency` {number|boolean} If a number is provided, then that many tests would run in parallel within the application thread. If `true`, all scheduled asynchronous tests run concurrently within the thread. If `false`, only one test runs at a time. If unspecified, subtests inherit this value from their parent. **Default:** `false`.",
                      "name": "concurrency",
                      "type": "number|boolean",
                      "default": "`false`",
                      "desc": "If a number is provided, then that many tests would run in parallel within the application thread. If `true`, all scheduled asynchronous tests run concurrently within the thread. If `false`, only one test runs at a time. If unspecified, subtests inherit this value from their parent."
                    },
                    {
                      "textRaw": "`only` {boolean} If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped. **Default:** `false`.",
                      "name": "only",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped."
                    },
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress test.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress test."
                    },
                    {
                      "textRaw": "`skip` {boolean|string} If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test. **Default:** `false`.",
                      "name": "skip",
                      "type": "boolean|string",
                      "default": "`false`",
                      "desc": "If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test."
                    },
                    {
                      "textRaw": "`todo` {boolean|string} If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`. **Default:** `false`.",
                      "name": "todo",
                      "type": "boolean|string",
                      "default": "`false`",
                      "desc": "If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent."
                    },
                    {
                      "textRaw": "`plan` {number} The number of assertions and subtests expected to be run in the test. If the number of assertions run in the test does not match the number specified in the plan, the test will fail. **Default:** `undefined`.",
                      "name": "plan",
                      "type": "number",
                      "default": "`undefined`",
                      "desc": "The number of assertions and subtests expected to be run in the test. If the number of assertions run in the test does not match the number specified in the plan, the test will fail."
                    }
                  ]
                },
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument."
                }
              ]
            }
          ],
          "desc": "<p>The <code>test()</code> function is the value imported from the <code>test</code> module. Each\ninvocation of this function results in reporting the test to the <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<p>The <code>TestContext</code> object passed to the <code>fn</code> argument can be used to perform\nactions related to the current test. Examples include skipping the test, adding\nadditional diagnostic information, or creating subtests.</p>\n<p><code>test()</code> returns a <code>Promise</code> that fulfills once the test completes.\nif <code>test()</code> is called within a suite, it fulfills immediately.\nThe return value can usually be discarded for top level tests.\nHowever, the return value from subtests should be used to prevent the parent\ntest from finishing first and cancelling the subtest\nas shown in the following example.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  // The setTimeout() in the following subtest would cause it to outlive its\n  // parent test if 'await' is removed on the next line. Once the parent test\n  // completes, it will cancel any outstanding subtests.\n  await t.test('longer running subtest', async (t) => {\n    return new Promise((resolve, reject) => {\n      setTimeout(resolve, 1000);\n    });\n  });\n});\n</code></pre>\n<p>The <code>timeout</code> option can be used to fail the test if it takes longer than\n<code>timeout</code> milliseconds to complete. However, it is not a reliable mechanism for\ncanceling tests because a running test might block the application thread and\nthus prevent the scheduled cancellation.</p>"
        },
        {
          "textRaw": "`test.skip([name][, options][, fn])`",
          "type": "method",
          "name": "skip",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for skipping a test,\nsame as <a href=\"#testname-options-fn\"><code>test([name], { skip: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`test.todo([name][, options][, fn])`",
          "type": "method",
          "name": "todo",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a test as <code>TODO</code>,\nsame as <a href=\"#testname-options-fn\"><code>test([name], { todo: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`test.only([name][, options][, fn])`",
          "type": "method",
          "name": "only",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a test as <code>only</code>,\nsame as <a href=\"#testname-options-fn\"><code>test([name], { only: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`describe([name][, options][, fn])`",
          "type": "method",
          "name": "describe",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Alias for <a href=\"#suitename-options-fn\"><code>suite()</code></a>.</p>\n<p>The <code>describe()</code> function is imported from the <code>node:test</code> module.</p>"
        },
        {
          "textRaw": "`describe.skip([name][, options][, fn])`",
          "type": "method",
          "name": "skip",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for skipping a suite. This is the same as\n<a href=\"#describename-options-fn\"><code>describe([name], { skip: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`describe.todo([name][, options][, fn])`",
          "type": "method",
          "name": "todo",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a suite as <code>TODO</code>. This is the same as\n<a href=\"#describename-options-fn\"><code>describe([name], { todo: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`describe.only([name][, options][, fn])`",
          "type": "method",
          "name": "only",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a suite as <code>only</code>. This is the same as\n<a href=\"#describename-options-fn\"><code>describe([name], { only: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`it([name][, options][, fn])`",
          "type": "method",
          "name": "it",
          "meta": {
            "added": [
              "v18.6.0",
              "v16.17.0"
            ],
            "changes": [
              {
                "version": [
                  "v19.8.0",
                  "v18.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/46889",
                "description": "Calling `it()` is now equivalent to calling `test()`."
              }
            ]
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Alias for <a href=\"#testname-options-fn\"><code>test()</code></a>.</p>\n<p>The <code>it()</code> function is imported from the <code>node:test</code> module.</p>"
        },
        {
          "textRaw": "`it.skip([name][, options][, fn])`",
          "type": "method",
          "name": "skip",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for skipping a test,\nsame as <a href=\"#testname-options-fn\"><code>it([name], { skip: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`it.todo([name][, options][, fn])`",
          "type": "method",
          "name": "todo",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a test as <code>TODO</code>,\nsame as <a href=\"#testname-options-fn\"><code>it([name], { todo: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`it.only([name][, options][, fn])`",
          "type": "method",
          "name": "only",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a test as <code>only</code>,\nsame as <a href=\"#testname-options-fn\"><code>it([name], { only: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`before([fn][, options])`",
          "type": "method",
          "name": "before",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function creates a hook that runs before executing a suite.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  before(() => console.log('about to run some test'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`after([fn][, options])`",
          "type": "method",
          "name": "after",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function creates a hook that runs after executing a suite.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  after(() => console.log('finished running tests'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>\n<p><strong>Note:</strong> The <code>after</code> hook is guaranteed to run,\neven if tests within the suite fail.</p>"
        },
        {
          "textRaw": "`beforeEach([fn][, options])`",
          "type": "method",
          "name": "beforeEach",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function creates a hook that runs before each test in the current suite.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  beforeEach(() => console.log('about to run a test'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`afterEach([fn][, options])`",
          "type": "method",
          "name": "afterEach",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function creates a hook that runs after each test in the current suite.\nThe <code>afterEach()</code> hook is run even if the test fails.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  afterEach(() => console.log('finished running a test'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `MockFunctionContext`",
          "type": "class",
          "name": "MockFunctionContext",
          "meta": {
            "added": [
              "v19.1.0",
              "v18.13.0"
            ],
            "changes": []
          },
          "desc": "<p>The <code>MockFunctionContext</code> class is used to inspect or manipulate the behavior of\nmocks created via the <a href=\"#class-mocktracker\"><code>MockTracker</code></a> APIs.</p>",
          "properties": [
            {
              "textRaw": "`calls` {Array}",
              "type": "Array",
              "name": "calls",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "desc": "<p>A getter that returns a copy of the internal array used to track calls to the\nmock. Each entry in the array is an object with the following properties.</p>\n<ul>\n<li><code>arguments</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\" class=\"type\">&lt;Array&gt;</a> An array of the arguments passed to the mock function.</li>\n<li><code>error</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types\" class=\"type\">&lt;any&gt;</a> If the mocked function threw then this property contains the\nthrown value. <strong>Default:</strong> <code>undefined</code>.</li>\n<li><code>result</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types\" class=\"type\">&lt;any&gt;</a> The value returned by the mocked function.</li>\n<li><code>stack</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\">&lt;Error&gt;</a> An <code>Error</code> object whose stack can be used to determine the\ncallsite of the mocked function invocation.</li>\n<li><code>target</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\">&lt;Function&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type\" class=\"type\">&lt;undefined&gt;</a> If the mocked function is a constructor, this\nfield contains the class being constructed. Otherwise this will be\n<code>undefined</code>.</li>\n<li><code>this</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types\" class=\"type\">&lt;any&gt;</a> The mocked function's <code>this</code> value.</li>\n</ul>"
            }
          ],
          "methods": [
            {
              "textRaw": "`ctx.callCount()`",
              "type": "method",
              "name": "callCount",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {integer} The number of times that this mock has been invoked.",
                    "name": "return",
                    "type": "integer",
                    "desc": "The number of times that this mock has been invoked."
                  },
                  "params": []
                }
              ],
              "desc": "<p>This function returns the number of times that this mock has been invoked. This\nfunction is more efficient than checking <code>ctx.calls.length</code> because <code>ctx.calls</code>\nis a getter that creates a copy of the internal call tracking array.</p>"
            },
            {
              "textRaw": "`ctx.mockImplementation(implementation)`",
              "type": "method",
              "name": "mockImplementation",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} The function to be used as the mock's new implementation.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "desc": "The function to be used as the mock's new implementation."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to change the behavior of an existing mock.</p>\n<p>The following example creates a mock function using <code>t.mock.fn()</code>, calls the\nmock function, and then changes the mock implementation to a different function.</p>\n<pre><code class=\"language-js\">test('changes a mock behavior', (t) => {\n  let cnt = 0;\n\n  function addOne() {\n    cnt++;\n    return cnt;\n  }\n\n  function addTwo() {\n    cnt += 2;\n    return cnt;\n  }\n\n  const fn = t.mock.fn(addOne);\n\n  assert.strictEqual(fn(), 1);\n  fn.mock.mockImplementation(addTwo);\n  assert.strictEqual(fn(), 3);\n  assert.strictEqual(fn(), 5);\n});\n</code></pre>"
            },
            {
              "textRaw": "`ctx.mockImplementationOnce(implementation[, onCall])`",
              "type": "method",
              "name": "mockImplementationOnce",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} The function to be used as the mock's implementation for the invocation number specified by `onCall`.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "desc": "The function to be used as the mock's implementation for the invocation number specified by `onCall`."
                    },
                    {
                      "textRaw": "`onCall` {integer} The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown. **Default:** The number of the next invocation.",
                      "name": "onCall",
                      "type": "integer",
                      "default": "The number of the next invocation",
                      "desc": "The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to change the behavior of an existing mock for a single\ninvocation. Once invocation <code>onCall</code> has occurred, the mock will revert to\nwhatever behavior it would have used had <code>mockImplementationOnce()</code> not been\ncalled.</p>\n<p>The following example creates a mock function using <code>t.mock.fn()</code>, calls the\nmock function, changes the mock implementation to a different function for the\nnext invocation, and then resumes its previous behavior.</p>\n<pre><code class=\"language-js\">test('changes a mock behavior once', (t) => {\n  let cnt = 0;\n\n  function addOne() {\n    cnt++;\n    return cnt;\n  }\n\n  function addTwo() {\n    cnt += 2;\n    return cnt;\n  }\n\n  const fn = t.mock.fn(addOne);\n\n  assert.strictEqual(fn(), 1);\n  fn.mock.mockImplementationOnce(addTwo);\n  assert.strictEqual(fn(), 3);\n  assert.strictEqual(fn(), 4);\n});\n</code></pre>"
            },
            {
              "textRaw": "`ctx.resetCalls()`",
              "type": "method",
              "name": "resetCalls",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the call history of the mock function.</p>"
            },
            {
              "textRaw": "`ctx.restore()`",
              "type": "method",
              "name": "restore",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the implementation of the mock function to its original behavior. The\nmock can still be used after calling this function.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `MockModuleContext`",
          "type": "class",
          "name": "MockModuleContext",
          "meta": {
            "added": [
              "v22.3.0",
              "v20.18.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": ".0 - Early development",
          "desc": "<p>The <code>MockModuleContext</code> class is used to manipulate the behavior of module mocks\ncreated via the <a href=\"#class-mocktracker\"><code>MockTracker</code></a> APIs.</p>",
          "methods": [
            {
              "textRaw": "`ctx.restore()`",
              "type": "method",
              "name": "restore",
              "meta": {
                "added": [
                  "v22.3.0",
                  "v20.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the implementation of the mock module.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `MockTracker`",
          "type": "class",
          "name": "MockTracker",
          "meta": {
            "added": [
              "v19.1.0",
              "v18.13.0"
            ],
            "changes": []
          },
          "desc": "<p>The <code>MockTracker</code> class is used to manage mocking functionality. The test runner\nmodule provides a top level <code>mock</code> export which is a <code>MockTracker</code> instance.\nEach test also provides its own <code>MockTracker</code> instance via the test context's\n<code>mock</code> property.</p>",
          "methods": [
            {
              "textRaw": "`mock.fn([original[, implementation]][, options])`",
              "type": "method",
              "name": "fn",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Proxy} The mocked function. The mocked function contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked function.",
                    "name": "return",
                    "type": "Proxy",
                    "desc": "The mocked function. The mocked function contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked function."
                  },
                  "params": [
                    {
                      "textRaw": "`original` {Function|AsyncFunction} An optional function to create a mock on. **Default:** A no-op function.",
                      "name": "original",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "An optional function to create a mock on."
                    },
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`. **Default:** The function specified by `original`.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "default": "The function specified by `original`",
                      "desc": "An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`."
                    },
                    {
                      "textRaw": "`options` {Object} Optional configuration options for the mock function. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Optional configuration options for the mock function. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`times` {integer} The number of times that the mock will use the behavior of `implementation`. Once the mock function has been called `times` times, it will automatically restore the behavior of `original`. This value must be an integer greater than zero. **Default:** `Infinity`.",
                          "name": "times",
                          "type": "integer",
                          "default": "`Infinity`",
                          "desc": "The number of times that the mock will use the behavior of `implementation`. Once the mock function has been called `times` times, it will automatically restore the behavior of `original`. This value must be an integer greater than zero."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a mock function.</p>\n<p>The following example creates a mock function that increments a counter by one\non each invocation. The <code>times</code> option is used to modify the mock behavior such\nthat the first two invocations add two to the counter instead of one.</p>\n<pre><code class=\"language-js\">test('mocks a counting function', (t) => {\n  let cnt = 0;\n\n  function addOne() {\n    cnt++;\n    return cnt;\n  }\n\n  function addTwo() {\n    cnt += 2;\n    return cnt;\n  }\n\n  const fn = t.mock.fn(addOne, addTwo, { times: 2 });\n\n  assert.strictEqual(fn(), 2);\n  assert.strictEqual(fn(), 4);\n  assert.strictEqual(fn(), 5);\n  assert.strictEqual(fn(), 6);\n});\n</code></pre>"
            },
            {
              "textRaw": "`mock.getter(object, methodName[, implementation][, options])`",
              "type": "method",
              "name": "getter",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function is syntax sugar for <a href=\"#mockmethodobject-methodname-implementation-options\"><code>MockTracker.method</code></a> with <code>options.getter</code>\nset to <code>true</code>.</p>"
            },
            {
              "textRaw": "`mock.method(object, methodName[, implementation][, options])`",
              "type": "method",
              "name": "method",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Proxy} The mocked method. The mocked method contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked method.",
                    "name": "return",
                    "type": "Proxy",
                    "desc": "The mocked method. The mocked method contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked method."
                  },
                  "params": [
                    {
                      "textRaw": "`object` {Object} The object whose method is being mocked.",
                      "name": "object",
                      "type": "Object",
                      "desc": "The object whose method is being mocked."
                    },
                    {
                      "textRaw": "`methodName` {string|symbol} The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.",
                      "name": "methodName",
                      "type": "string|symbol",
                      "desc": "The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown."
                    },
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} An optional function used as the mock implementation for `object[methodName]`. **Default:** The original method specified by `object[methodName]`.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "default": "The original method specified by `object[methodName]`",
                      "desc": "An optional function used as the mock implementation for `object[methodName]`."
                    },
                    {
                      "textRaw": "`options` {Object} Optional configuration options for the mock method. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Optional configuration options for the mock method. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`getter` {boolean} If `true`, `object[methodName]` is treated as a getter. This option cannot be used with the `setter` option. **Default:** false.",
                          "name": "getter",
                          "type": "boolean",
                          "default": "false",
                          "desc": "If `true`, `object[methodName]` is treated as a getter. This option cannot be used with the `setter` option."
                        },
                        {
                          "textRaw": "`setter` {boolean} If `true`, `object[methodName]` is treated as a setter. This option cannot be used with the `getter` option. **Default:** false.",
                          "name": "setter",
                          "type": "boolean",
                          "default": "false",
                          "desc": "If `true`, `object[methodName]` is treated as a setter. This option cannot be used with the `getter` option."
                        },
                        {
                          "textRaw": "`times` {integer} The number of times that the mock will use the behavior of `implementation`. Once the mocked method has been called `times` times, it will automatically restore the original behavior. This value must be an integer greater than zero. **Default:** `Infinity`.",
                          "name": "times",
                          "type": "integer",
                          "default": "`Infinity`",
                          "desc": "The number of times that the mock will use the behavior of `implementation`. Once the mocked method has been called `times` times, it will automatically restore the original behavior. This value must be an integer greater than zero."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a mock on an existing object method. The\nfollowing example demonstrates how a mock is created on an existing object\nmethod.</p>\n<pre><code class=\"language-js\">test('spies on an object method', (t) => {\n  const number = {\n    value: 5,\n    subtract(a) {\n      return this.value - a;\n    },\n  };\n\n  t.mock.method(number, 'subtract');\n  assert.strictEqual(number.subtract.mock.callCount(), 0);\n  assert.strictEqual(number.subtract(3), 2);\n  assert.strictEqual(number.subtract.mock.callCount(), 1);\n\n  const call = number.subtract.mock.calls[0];\n\n  assert.deepStrictEqual(call.arguments, [3]);\n  assert.strictEqual(call.result, 2);\n  assert.strictEqual(call.error, undefined);\n  assert.strictEqual(call.target, undefined);\n  assert.strictEqual(call.this, number);\n});\n</code></pre>"
            },
            {
              "textRaw": "`mock.module(specifier[, options])`",
              "type": "method",
              "name": "module",
              "meta": {
                "added": [
                  "v22.3.0",
                  "v20.18.0"
                ],
                "changes": []
              },
              "stability": 1,
              "stabilityText": ".0 - Early development",
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {MockModuleContext} An object that can be used to manipulate the mock.",
                    "name": "return",
                    "type": "MockModuleContext",
                    "desc": "An object that can be used to manipulate the mock."
                  },
                  "params": [
                    {
                      "textRaw": "`specifier` {string|URL} A string identifying the module to mock.",
                      "name": "specifier",
                      "type": "string|URL",
                      "desc": "A string identifying the module to mock."
                    },
                    {
                      "textRaw": "`options` {Object} Optional configuration options for the mock module. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Optional configuration options for the mock module. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`cache` {boolean} If `false`, each call to `require()` or `import()` generates a new mock module. If `true`, subsequent calls will return the same module mock, and the mock module is inserted into the CommonJS cache. **Default:** false.",
                          "name": "cache",
                          "type": "boolean",
                          "default": "false",
                          "desc": "If `false`, each call to `require()` or `import()` generates a new mock module. If `true`, subsequent calls will return the same module mock, and the mock module is inserted into the CommonJS cache."
                        },
                        {
                          "textRaw": "`defaultExport` {any} An optional value used as the mocked module's default export. If this value is not provided, ESM mocks do not include a default export. If the mock is a CommonJS or builtin module, this setting is used as the value of `module.exports`. If this value is not provided, CJS and builtin mocks use an empty object as the value of `module.exports`.",
                          "name": "defaultExport",
                          "type": "any",
                          "desc": "An optional value used as the mocked module's default export. If this value is not provided, ESM mocks do not include a default export. If the mock is a CommonJS or builtin module, this setting is used as the value of `module.exports`. If this value is not provided, CJS and builtin mocks use an empty object as the value of `module.exports`."
                        },
                        {
                          "textRaw": "`namedExports` {Object} An optional object whose keys and values are used to create the named exports of the mock module. If the mock is a CommonJS or builtin module, these values are copied onto `module.exports`. Therefore, if a mock is created with both named exports and a non-object default export, the mock will throw an exception when used as a CJS or builtin module.",
                          "name": "namedExports",
                          "type": "Object",
                          "desc": "An optional object whose keys and values are used to create the named exports of the mock module. If the mock is a CommonJS or builtin module, these values are copied onto `module.exports`. Therefore, if a mock is created with both named exports and a non-object default export, the mock will throw an exception when used as a CJS or builtin module."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to mock the exports of ECMAScript modules, CommonJS\nmodules, and Node.js builtin modules. Any references to the original module\nprior to mocking are not impacted. In order to enable module mocking, Node.js must\nbe started with the <a href=\"cli.html#--experimental-test-module-mocks\"><code>--experimental-test-module-mocks</code></a> command-line flag.</p>\n<p>The following example demonstrates how a mock is created for a module.</p>\n<pre><code class=\"language-js\">test('mocks a builtin module in both module systems', async (t) => {\n  // Create a mock of 'node:readline' with a named export named 'fn', which\n  // does not exist in the original 'node:readline' module.\n  const mock = t.mock.module('node:readline', {\n    namedExports: { fn() { return 42; } },\n  });\n\n  let esmImpl = await import('node:readline');\n  let cjsImpl = require('node:readline');\n\n  // cursorTo() is an export of the original 'node:readline' module.\n  assert.strictEqual(esmImpl.cursorTo, undefined);\n  assert.strictEqual(cjsImpl.cursorTo, undefined);\n  assert.strictEqual(esmImpl.fn(), 42);\n  assert.strictEqual(cjsImpl.fn(), 42);\n\n  mock.restore();\n\n  // The mock is restored, so the original builtin module is returned.\n  esmImpl = await import('node:readline');\n  cjsImpl = require('node:readline');\n\n  assert.strictEqual(typeof esmImpl.cursorTo, 'function');\n  assert.strictEqual(typeof cjsImpl.cursorTo, 'function');\n  assert.strictEqual(esmImpl.fn, undefined);\n  assert.strictEqual(cjsImpl.fn, undefined);\n});\n</code></pre>"
            },
            {
              "textRaw": "`mock.reset()`",
              "type": "method",
              "name": "reset",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function restores the default behavior of all mocks that were previously\ncreated by this <code>MockTracker</code> and disassociates the mocks from the\n<code>MockTracker</code> instance. Once disassociated, the mocks can still be used, but the\n<code>MockTracker</code> instance can no longer be used to reset their behavior or\notherwise interact with them.</p>\n<p>After each test completes, this function is called on the test context's\n<code>MockTracker</code>. If the global <code>MockTracker</code> is used extensively, calling this\nfunction manually is recommended.</p>"
            },
            {
              "textRaw": "`mock.restoreAll()`",
              "type": "method",
              "name": "restoreAll",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function restores the default behavior of all mocks that were previously\ncreated by this <code>MockTracker</code>. Unlike <code>mock.reset()</code>, <code>mock.restoreAll()</code> does\nnot disassociate the mocks from the <code>MockTracker</code> instance.</p>"
            },
            {
              "textRaw": "`mock.setter(object, methodName[, implementation][, options])`",
              "type": "method",
              "name": "setter",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function is syntax sugar for <a href=\"#mockmethodobject-methodname-implementation-options\"><code>MockTracker.method</code></a> with <code>options.setter</code>\nset to <code>true</code>.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `MockTimers`",
          "type": "class",
          "name": "MockTimers",
          "meta": {
            "added": [
              "v20.4.0",
              "v18.19.0"
            ],
            "changes": [
              {
                "version": "v23.1.0",
                "pr-url": "https://github.com/nodejs/node/pull/55398",
                "description": "The Mock Timers is now stable."
              }
            ]
          },
          "stability": 2,
          "stabilityText": "Stable",
          "desc": "<p>Mocking timers is a technique commonly used in software testing to simulate and\ncontrol the behavior of timers, such as <code>setInterval</code> and <code>setTimeout</code>,\nwithout actually waiting for the specified time intervals.</p>\n<p>MockTimers is also able to mock the <code>Date</code> object.</p>\n<p>The <a href=\"#class-mocktracker\"><code>MockTracker</code></a> provides a top-level <code>timers</code> export\nwhich is a <code>MockTimers</code> instance.</p>",
          "methods": [
            {
              "textRaw": "`timers.enable([enableOptions])`",
              "type": "method",
              "name": "enable",
              "meta": {
                "added": [
                  "v20.4.0",
                  "v18.19.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v21.2.0",
                      "v20.11.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/48638",
                    "description": "Updated parameters to be an option object with available APIs and the default initial epoch."
                  }
                ]
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Enables timer mocking for the specified timers.</p>\n<ul>\n<li><code>enableOptions</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\">&lt;Object&gt;</a> Optional configuration options for enabling timer\nmocking. The following properties are supported:\n<ul>\n<li><code>apis</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\" class=\"type\">&lt;Array&gt;</a> An optional array containing the timers to mock.\nThe currently supported timer values are <code>'setInterval'</code>, <code>'setTimeout'</code>, <code>'setImmediate'</code>,\nand <code>'Date'</code>. <strong>Default:</strong> <code>['setInterval', 'setTimeout', 'setImmediate', 'Date']</code>.\nIf no array is provided, all time related APIs (<code>'setInterval'</code>, <code>'clearInterval'</code>,\n<code>'setTimeout'</code>, <code>'clearTimeout'</code>, <code>'setImmediate'</code>, <code>'clearImmediate'</code>, and\n<code>'Date'</code>) will be mocked by default.</li>\n<li><code>now</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date\" class=\"type\">&lt;Date&gt;</a> An optional number or Date object representing the\ninitial time (in milliseconds) to use as the value\nfor <code>Date.now()</code>. <strong>Default:</strong> <code>0</code>.</li>\n</ul>\n</li>\n</ul>\n<p><strong>Note:</strong> When you enable mocking for a specific timer, its associated\nclear function will also be implicitly mocked.</p>\n<p><strong>Note:</strong> Mocking <code>Date</code> will affect the behavior of the mocked timers\nas they use the same internal clock.</p>\n<p>Example usage without setting initial time:</p>\n<pre><code class=\"language-mjs\">import { mock } from 'node:test';\nmock.timers.enable({ apis: ['setInterval'] });\n</code></pre>\n<pre><code class=\"language-cjs\">const { mock } = require('node:test');\nmock.timers.enable({ apis: ['setInterval'] });\n</code></pre>\n<p>The above example enables mocking for the <code>setInterval</code> timer and\nimplicitly mocks the <code>clearInterval</code> function. Only the <code>setInterval</code>\nand <code>clearInterval</code> functions from <a href=\"./timers.html\">node:timers</a>,\n<a href=\"./timers.html#timers-promises-api\">node:timers/promises</a>, and\n<code>globalThis</code> will be mocked.</p>\n<p>Example usage with initial time set</p>\n<pre><code class=\"language-mjs\">import { mock } from 'node:test';\nmock.timers.enable({ apis: ['Date'], now: 1000 });\n</code></pre>\n<pre><code class=\"language-cjs\">const { mock } = require('node:test');\nmock.timers.enable({ apis: ['Date'], now: 1000 });\n</code></pre>\n<p>Example usage with initial Date object as time set</p>\n<pre><code class=\"language-mjs\">import { mock } from 'node:test';\nmock.timers.enable({ apis: ['Date'], now: new Date() });\n</code></pre>\n<pre><code class=\"language-cjs\">const { mock } = require('node:test');\nmock.timers.enable({ apis: ['Date'], now: new Date() });\n</code></pre>\n<p>Alternatively, if you call <code>mock.timers.enable()</code> without any parameters:</p>\n<p>All timers (<code>'setInterval'</code>, <code>'clearInterval'</code>, <code>'setTimeout'</code>, <code>'clearTimeout'</code>,\n<code>'setImmediate'</code>, and <code>'clearImmediate'</code>) will be mocked. The <code>setInterval</code>,\n<code>clearInterval</code>, <code>setTimeout</code>, <code>clearTimeout</code>, <code>setImmediate</code>, and\n<code>clearImmediate</code> functions from <code>node:timers</code>, <code>node:timers/promises</code>, and\n<code>globalThis</code> will be mocked. As well as the global <code>Date</code> object.</p>"
            },
            {
              "textRaw": "`timers.reset()`",
              "type": "method",
              "name": "reset",
              "meta": {
                "added": [
                  "v20.4.0",
                  "v18.19.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function restores the default behavior of all mocks that were previously\ncreated by this  <code>MockTimers</code> instance and disassociates the mocks\nfrom the  <code>MockTracker</code> instance.</p>\n<p><strong>Note:</strong> After each test completes, this function is called on\nthe test context's  <code>MockTracker</code>.</p>\n<pre><code class=\"language-mjs\">import { mock } from 'node:test';\nmock.timers.reset();\n</code></pre>\n<pre><code class=\"language-cjs\">const { mock } = require('node:test');\nmock.timers.reset();\n</code></pre>"
            },
            {
              "textRaw": "`timers[Symbol.dispose]()`",
              "type": "method",
              "name": "[Symbol.dispose]",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Calls <code>timers.reset()</code>.</p>"
            },
            {
              "textRaw": "`timers.tick([milliseconds])`",
              "type": "method",
              "name": "tick",
              "meta": {
                "added": [
                  "v20.4.0",
                  "v18.19.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Advances time for all mocked timers.</p>\n<ul>\n<li><code>milliseconds</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a> The amount of time, in milliseconds,\nto advance the timers. <strong>Default:</strong> <code>1</code>.</li>\n</ul>\n<p><strong>Note:</strong> This diverges from how <code>setTimeout</code> in Node.js behaves and accepts\nonly positive numbers. In Node.js, <code>setTimeout</code> with negative numbers is\nonly supported for web compatibility reasons.</p>\n<p>The following example mocks a <code>setTimeout</code> function and\nby using <code>.tick</code> advances in\ntime triggering all pending timers.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n\n  setTimeout(fn, 9999);\n\n  assert.strictEqual(fn.mock.callCount(), 0);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n\n  assert.strictEqual(fn.mock.callCount(), 1);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n\n  setTimeout(fn, 9999);\n  assert.strictEqual(fn.mock.callCount(), 0);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n\n  assert.strictEqual(fn.mock.callCount(), 1);\n});\n</code></pre>\n<p>Alternatively, the <code>.tick</code> function can be called many times</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  const nineSecs = 9000;\n  setTimeout(fn, nineSecs);\n\n  const threeSeconds = 3000;\n  context.mock.timers.tick(threeSeconds);\n  context.mock.timers.tick(threeSeconds);\n  context.mock.timers.tick(threeSeconds);\n\n  assert.strictEqual(fn.mock.callCount(), 1);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  const nineSecs = 9000;\n  setTimeout(fn, nineSecs);\n\n  const threeSeconds = 3000;\n  context.mock.timers.tick(threeSeconds);\n  context.mock.timers.tick(threeSeconds);\n  context.mock.timers.tick(threeSeconds);\n\n  assert.strictEqual(fn.mock.callCount(), 1);\n});\n</code></pre>\n<p>Advancing time using <code>.tick</code> will also advance the time for any <code>Date</code> object\ncreated after the mock was enabled (if <code>Date</code> was also set to be mocked).</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  setTimeout(fn, 9999);\n\n  assert.strictEqual(fn.mock.callCount(), 0);\n  assert.strictEqual(Date.now(), 0);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n  assert.strictEqual(fn.mock.callCount(), 1);\n  assert.strictEqual(Date.now(), 9999);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n\n  setTimeout(fn, 9999);\n  assert.strictEqual(fn.mock.callCount(), 0);\n  assert.strictEqual(Date.now(), 0);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n  assert.strictEqual(fn.mock.callCount(), 1);\n  assert.strictEqual(Date.now(), 9999);\n});\n</code></pre>",
              "modules": [
                {
                  "textRaw": "Using clear functions",
                  "name": "using_clear_functions",
                  "desc": "<p>As mentioned, all clear functions from timers (<code>clearTimeout</code>, <code>clearInterval</code>,and\n<code>clearImmediate</code>) are implicitly mocked. Take a look at this example using <code>setTimeout</code>:</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  const id = setTimeout(fn, 9999);\n\n  // Implicitly mocked as well\n  clearTimeout(id);\n  context.mock.timers.tick(9999);\n\n  // As that setTimeout was cleared the mock function will never be called\n  assert.strictEqual(fn.mock.callCount(), 0);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {\n  const fn = context.mock.fn();\n\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  const id = setTimeout(fn, 9999);\n\n  // Implicitly mocked as well\n  clearTimeout(id);\n  context.mock.timers.tick(9999);\n\n  // As that setTimeout was cleared the mock function will never be called\n  assert.strictEqual(fn.mock.callCount(), 0);\n});\n</code></pre>",
                  "type": "module",
                  "displayName": "Using clear functions"
                },
                {
                  "textRaw": "Working with Node.js timers modules",
                  "name": "working_with_node.js_timers_modules",
                  "desc": "<p>Once you enable mocking timers, <a href=\"./timers.html\">node:timers</a>,\n<a href=\"./timers.html#timers-promises-api\">node:timers/promises</a> modules,\nand timers from the Node.js global context are enabled:</p>\n<p><strong>Note:</strong> Destructuring functions such as\n<code>import { setTimeout } from 'node:timers'</code> is currently\nnot supported by this API.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\nimport nodeTimers from 'node:timers';\nimport nodeTimersPromises from 'node:timers/promises';\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', async (context) => {\n  const globalTimeoutObjectSpy = context.mock.fn();\n  const nodeTimerSpy = context.mock.fn();\n  const nodeTimerPromiseSpy = context.mock.fn();\n\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  setTimeout(globalTimeoutObjectSpy, 9999);\n  nodeTimers.setTimeout(nodeTimerSpy, 9999);\n\n  const promise = nodeTimersPromises.setTimeout(9999).then(nodeTimerPromiseSpy);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n  assert.strictEqual(globalTimeoutObjectSpy.mock.callCount(), 1);\n  assert.strictEqual(nodeTimerSpy.mock.callCount(), 1);\n  await promise;\n  assert.strictEqual(nodeTimerPromiseSpy.mock.callCount(), 1);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\nconst nodeTimers = require('node:timers');\nconst nodeTimersPromises = require('node:timers/promises');\n\ntest('mocks setTimeout to be executed synchronously without having to actually wait for it', async (context) => {\n  const globalTimeoutObjectSpy = context.mock.fn();\n  const nodeTimerSpy = context.mock.fn();\n  const nodeTimerPromiseSpy = context.mock.fn();\n\n  // Optionally choose what to mock\n  context.mock.timers.enable({ apis: ['setTimeout'] });\n  setTimeout(globalTimeoutObjectSpy, 9999);\n  nodeTimers.setTimeout(nodeTimerSpy, 9999);\n\n  const promise = nodeTimersPromises.setTimeout(9999).then(nodeTimerPromiseSpy);\n\n  // Advance in time\n  context.mock.timers.tick(9999);\n  assert.strictEqual(globalTimeoutObjectSpy.mock.callCount(), 1);\n  assert.strictEqual(nodeTimerSpy.mock.callCount(), 1);\n  await promise;\n  assert.strictEqual(nodeTimerPromiseSpy.mock.callCount(), 1);\n});\n</code></pre>\n<p>In Node.js, <code>setInterval</code> from <a href=\"./timers.html#timers-promises-api\">node:timers/promises</a>\nis an <code>AsyncGenerator</code> and is also supported by this API:</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\nimport nodeTimersPromises from 'node:timers/promises';\ntest('should tick five times testing a real use case', async (context) => {\n  context.mock.timers.enable({ apis: ['setInterval'] });\n\n  const expectedIterations = 3;\n  const interval = 1000;\n  const startedAt = Date.now();\n  async function run() {\n    const times = [];\n    for await (const time of nodeTimersPromises.setInterval(interval, startedAt)) {\n      times.push(time);\n      if (times.length === expectedIterations) break;\n    }\n    return times;\n  }\n\n  const r = run();\n  context.mock.timers.tick(interval);\n  context.mock.timers.tick(interval);\n  context.mock.timers.tick(interval);\n\n  const timeResults = await r;\n  assert.strictEqual(timeResults.length, expectedIterations);\n  for (let it = 1; it &#x3C; expectedIterations; it++) {\n    assert.strictEqual(timeResults[it - 1], startedAt + (interval * it));\n  }\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\nconst nodeTimersPromises = require('node:timers/promises');\ntest('should tick five times testing a real use case', async (context) => {\n  context.mock.timers.enable({ apis: ['setInterval'] });\n\n  const expectedIterations = 3;\n  const interval = 1000;\n  const startedAt = Date.now();\n  async function run() {\n    const times = [];\n    for await (const time of nodeTimersPromises.setInterval(interval, startedAt)) {\n      times.push(time);\n      if (times.length === expectedIterations) break;\n    }\n    return times;\n  }\n\n  const r = run();\n  context.mock.timers.tick(interval);\n  context.mock.timers.tick(interval);\n  context.mock.timers.tick(interval);\n\n  const timeResults = await r;\n  assert.strictEqual(timeResults.length, expectedIterations);\n  for (let it = 1; it &#x3C; expectedIterations; it++) {\n    assert.strictEqual(timeResults[it - 1], startedAt + (interval * it));\n  }\n});\n</code></pre>",
                  "type": "module",
                  "displayName": "Working with Node.js timers modules"
                }
              ]
            },
            {
              "textRaw": "`timers.runAll()`",
              "type": "method",
              "name": "runAll",
              "meta": {
                "added": [
                  "v20.4.0",
                  "v18.19.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Triggers all pending mocked timers immediately. If the <code>Date</code> object is also\nmocked, it will also advance the <code>Date</code> object to the furthest timer's time.</p>\n<p>The example below triggers all pending timers immediately,\ncausing them to execute without any delay.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('runAll functions following the given order', (context) => {\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const results = [];\n  setTimeout(() => results.push(1), 9999);\n\n  // Notice that if both timers have the same timeout,\n  // the order of execution is guaranteed\n  setTimeout(() => results.push(3), 8888);\n  setTimeout(() => results.push(2), 8888);\n\n  assert.deepStrictEqual(results, []);\n\n  context.mock.timers.runAll();\n  assert.deepStrictEqual(results, [3, 2, 1]);\n  // The Date object is also advanced to the furthest timer's time\n  assert.strictEqual(Date.now(), 9999);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('runAll functions following the given order', (context) => {\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const results = [];\n  setTimeout(() => results.push(1), 9999);\n\n  // Notice that if both timers have the same timeout,\n  // the order of execution is guaranteed\n  setTimeout(() => results.push(3), 8888);\n  setTimeout(() => results.push(2), 8888);\n\n  assert.deepStrictEqual(results, []);\n\n  context.mock.timers.runAll();\n  assert.deepStrictEqual(results, [3, 2, 1]);\n  // The Date object is also advanced to the furthest timer's time\n  assert.strictEqual(Date.now(), 9999);\n});\n</code></pre>\n<p><strong>Note:</strong> The <code>runAll()</code> function is specifically designed for\ntriggering timers in the context of timer mocking.\nIt does not have any effect on real-time system\nclocks or actual timers outside of the mocking environment.</p>"
            },
            {
              "textRaw": "`timers.setTime(milliseconds)`",
              "type": "method",
              "name": "setTime",
              "meta": {
                "added": [
                  "v21.2.0",
                  "v20.11.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Sets the current Unix timestamp that will be used as reference for any mocked\n<code>Date</code> objects.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('runAll functions following the given order', (context) => {\n  const now = Date.now();\n  const setTime = 1000;\n  // Date.now is not mocked\n  assert.deepStrictEqual(Date.now(), now);\n\n  context.mock.timers.enable({ apis: ['Date'] });\n  context.mock.timers.setTime(setTime);\n  // Date.now is now 1000\n  assert.strictEqual(Date.now(), setTime);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('setTime replaces current time', (context) => {\n  const now = Date.now();\n  const setTime = 1000;\n  // Date.now is not mocked\n  assert.deepStrictEqual(Date.now(), now);\n\n  context.mock.timers.enable({ apis: ['Date'] });\n  context.mock.timers.setTime(setTime);\n  // Date.now is now 1000\n  assert.strictEqual(Date.now(), setTime);\n});\n</code></pre>",
              "modules": [
                {
                  "textRaw": "Dates and Timers working together",
                  "name": "dates_and_timers_working_together",
                  "desc": "<p>Dates and timer objects are dependent on each other. If you use <code>setTime()</code> to\npass the current time to the mocked <code>Date</code> object, the set timers with\n<code>setTimeout</code> and <code>setInterval</code> will <strong>not</strong> be affected.</p>\n<p>However, the <code>tick</code> method <strong>will</strong> advanced the mocked <code>Date</code> object.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('runAll functions following the given order', (context) => {\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const results = [];\n  setTimeout(() => results.push(1), 9999);\n\n  assert.deepStrictEqual(results, []);\n  context.mock.timers.setTime(12000);\n  assert.deepStrictEqual(results, []);\n  // The date is advanced but the timers don't tick\n  assert.strictEqual(Date.now(), 12000);\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst { test } = require('node:test');\n\ntest('runAll functions following the given order', (context) => {\n  context.mock.timers.enable({ apis: ['setTimeout', 'Date'] });\n  const results = [];\n  setTimeout(() => results.push(1), 9999);\n\n  assert.deepStrictEqual(results, []);\n  context.mock.timers.setTime(12000);\n  assert.deepStrictEqual(results, []);\n  // The date is advanced but the timers don't tick\n  assert.strictEqual(Date.now(), 12000);\n});\n</code></pre>",
                  "type": "module",
                  "displayName": "Dates and Timers working together"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "Class: `TestsStream`",
          "type": "class",
          "name": "TestsStream",
          "meta": {
            "added": [
              "v18.9.0",
              "v16.19.0"
            ],
            "changes": [
              {
                "version": [
                  "v20.0.0",
                  "v19.9.0",
                  "v18.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/47094",
                "description": "added type to test:pass and test:fail events for when the test is a suite."
              }
            ]
          },
          "desc": "<ul>\n<li>Extends <a href=\"stream.html#class-streamreadable\" class=\"type\">&lt;Readable&gt;</a></li>\n</ul>\n<p>A successful call to <a href=\"#runoptions\"><code>run()</code></a> method will return a new <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>\nobject, streaming a series of events representing the execution of the tests.\n<code>TestsStream</code> will emit events, in the order of the tests definition</p>\n<p>Some of the events are guaranteed to be emitted in the same order as the tests\nare defined, while others are emitted in the order that the tests execute.</p>",
          "events": [
            {
              "textRaw": "Event: `'test:coverage'`",
              "type": "event",
              "name": "test:coverage",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`summary` {Object} An object containing the coverage report.",
                      "name": "summary",
                      "type": "Object",
                      "desc": "An object containing the coverage report.",
                      "options": [
                        {
                          "textRaw": "`files` {Array} An array of coverage reports for individual files. Each report is an object with the following schema:",
                          "name": "files",
                          "type": "Array",
                          "desc": "An array of coverage reports for individual files. Each report is an object with the following schema:",
                          "options": [
                            {
                              "textRaw": "`path` {string} The absolute path of the file.",
                              "name": "path",
                              "type": "string",
                              "desc": "The absolute path of the file."
                            },
                            {
                              "textRaw": "`totalLineCount` {number} The total number of lines.",
                              "name": "totalLineCount",
                              "type": "number",
                              "desc": "The total number of lines."
                            },
                            {
                              "textRaw": "`totalBranchCount` {number} The total number of branches.",
                              "name": "totalBranchCount",
                              "type": "number",
                              "desc": "The total number of branches."
                            },
                            {
                              "textRaw": "`totalFunctionCount` {number} The total number of functions.",
                              "name": "totalFunctionCount",
                              "type": "number",
                              "desc": "The total number of functions."
                            },
                            {
                              "textRaw": "`coveredLineCount` {number} The number of covered lines.",
                              "name": "coveredLineCount",
                              "type": "number",
                              "desc": "The number of covered lines."
                            },
                            {
                              "textRaw": "`coveredBranchCount` {number} The number of covered branches.",
                              "name": "coveredBranchCount",
                              "type": "number",
                              "desc": "The number of covered branches."
                            },
                            {
                              "textRaw": "`coveredFunctionCount` {number} The number of covered functions.",
                              "name": "coveredFunctionCount",
                              "type": "number",
                              "desc": "The number of covered functions."
                            },
                            {
                              "textRaw": "`coveredLinePercent` {number} The percentage of lines covered.",
                              "name": "coveredLinePercent",
                              "type": "number",
                              "desc": "The percentage of lines covered."
                            },
                            {
                              "textRaw": "`coveredBranchPercent` {number} The percentage of branches covered.",
                              "name": "coveredBranchPercent",
                              "type": "number",
                              "desc": "The percentage of branches covered."
                            },
                            {
                              "textRaw": "`coveredFunctionPercent` {number} The percentage of functions covered.",
                              "name": "coveredFunctionPercent",
                              "type": "number",
                              "desc": "The percentage of functions covered."
                            },
                            {
                              "textRaw": "`functions` {Array} An array of functions representing function coverage.",
                              "name": "functions",
                              "type": "Array",
                              "desc": "An array of functions representing function coverage.",
                              "options": [
                                {
                                  "textRaw": "`name` {string} The name of the function.",
                                  "name": "name",
                                  "type": "string",
                                  "desc": "The name of the function."
                                },
                                {
                                  "textRaw": "`line` {number} The line number where the function is defined.",
                                  "name": "line",
                                  "type": "number",
                                  "desc": "The line number where the function is defined."
                                },
                                {
                                  "textRaw": "`count` {number} The number of times the function was called.",
                                  "name": "count",
                                  "type": "number",
                                  "desc": "The number of times the function was called."
                                }
                              ]
                            },
                            {
                              "textRaw": "`branches` {Array} An array of branches representing branch coverage.",
                              "name": "branches",
                              "type": "Array",
                              "desc": "An array of branches representing branch coverage.",
                              "options": [
                                {
                                  "textRaw": "`line` {number} The line number where the branch is defined.",
                                  "name": "line",
                                  "type": "number",
                                  "desc": "The line number where the branch is defined."
                                },
                                {
                                  "textRaw": "`count` {number} The number of times the branch was taken.",
                                  "name": "count",
                                  "type": "number",
                                  "desc": "The number of times the branch was taken."
                                }
                              ]
                            },
                            {
                              "textRaw": "`lines` {Array} An array of lines representing line numbers and the number of times they were covered.",
                              "name": "lines",
                              "type": "Array",
                              "desc": "An array of lines representing line numbers and the number of times they were covered.",
                              "options": [
                                {
                                  "textRaw": "`line` {number} The line number.",
                                  "name": "line",
                                  "type": "number",
                                  "desc": "The line number."
                                },
                                {
                                  "textRaw": "`count` {number} The number of times the line was covered.",
                                  "name": "count",
                                  "type": "number",
                                  "desc": "The number of times the line was covered."
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "textRaw": "`thresholds` {Object} An object containing whether or not the coverage for each coverage type.",
                          "name": "thresholds",
                          "type": "Object",
                          "desc": "An object containing whether or not the coverage for each coverage type.",
                          "options": [
                            {
                              "textRaw": "`function` {number} The function coverage threshold.",
                              "name": "function",
                              "type": "number",
                              "desc": "The function coverage threshold."
                            },
                            {
                              "textRaw": "`branch` {number} The branch coverage threshold.",
                              "name": "branch",
                              "type": "number",
                              "desc": "The branch coverage threshold."
                            },
                            {
                              "textRaw": "`line` {number} The line coverage threshold.",
                              "name": "line",
                              "type": "number",
                              "desc": "The line coverage threshold."
                            }
                          ]
                        },
                        {
                          "textRaw": "`totals` {Object} An object containing a summary of coverage for all files.",
                          "name": "totals",
                          "type": "Object",
                          "desc": "An object containing a summary of coverage for all files.",
                          "options": [
                            {
                              "textRaw": "`totalLineCount` {number} The total number of lines.",
                              "name": "totalLineCount",
                              "type": "number",
                              "desc": "The total number of lines."
                            },
                            {
                              "textRaw": "`totalBranchCount` {number} The total number of branches.",
                              "name": "totalBranchCount",
                              "type": "number",
                              "desc": "The total number of branches."
                            },
                            {
                              "textRaw": "`totalFunctionCount` {number} The total number of functions.",
                              "name": "totalFunctionCount",
                              "type": "number",
                              "desc": "The total number of functions."
                            },
                            {
                              "textRaw": "`coveredLineCount` {number} The number of covered lines.",
                              "name": "coveredLineCount",
                              "type": "number",
                              "desc": "The number of covered lines."
                            },
                            {
                              "textRaw": "`coveredBranchCount` {number} The number of covered branches.",
                              "name": "coveredBranchCount",
                              "type": "number",
                              "desc": "The number of covered branches."
                            },
                            {
                              "textRaw": "`coveredFunctionCount` {number} The number of covered functions.",
                              "name": "coveredFunctionCount",
                              "type": "number",
                              "desc": "The number of covered functions."
                            },
                            {
                              "textRaw": "`coveredLinePercent` {number} The percentage of lines covered.",
                              "name": "coveredLinePercent",
                              "type": "number",
                              "desc": "The percentage of lines covered."
                            },
                            {
                              "textRaw": "`coveredBranchPercent` {number} The percentage of branches covered.",
                              "name": "coveredBranchPercent",
                              "type": "number",
                              "desc": "The percentage of branches covered."
                            },
                            {
                              "textRaw": "`coveredFunctionPercent` {number} The percentage of functions covered.",
                              "name": "coveredFunctionPercent",
                              "type": "number",
                              "desc": "The percentage of functions covered."
                            }
                          ]
                        },
                        {
                          "textRaw": "`workingDirectory` {string} The working directory when code coverage began. This is useful for displaying relative path names in case the tests changed the working directory of the Node.js process.",
                          "name": "workingDirectory",
                          "type": "string",
                          "desc": "The working directory when code coverage began. This is useful for displaying relative path names in case the tests changed the working directory of the Node.js process."
                        }
                      ]
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when code coverage is enabled and all tests have completed.</p>"
            },
            {
              "textRaw": "Event: `'test:complete'`",
              "type": "event",
              "name": "test:complete",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`details` {Object} Additional execution metadata.",
                      "name": "details",
                      "type": "Object",
                      "desc": "Additional execution metadata.",
                      "options": [
                        {
                          "textRaw": "`passed` {boolean} Whether the test passed or not.",
                          "name": "passed",
                          "type": "boolean",
                          "desc": "Whether the test passed or not."
                        },
                        {
                          "textRaw": "`duration_ms` {number} The duration of the test in milliseconds.",
                          "name": "duration_ms",
                          "type": "number",
                          "desc": "The duration of the test in milliseconds."
                        },
                        {
                          "textRaw": "`error` {Error|undefined} An error wrapping the error thrown by the test if it did not pass.",
                          "name": "error",
                          "type": "Error|undefined",
                          "desc": "An error wrapping the error thrown by the test if it did not pass.",
                          "options": [
                            {
                              "textRaw": "`cause` {Error} The actual error thrown by the test.",
                              "name": "cause",
                              "type": "Error",
                              "desc": "The actual error thrown by the test."
                            }
                          ]
                        },
                        {
                          "textRaw": "`type` {string|undefined} The type of the test, used to denote whether this is a suite.",
                          "name": "type",
                          "type": "string|undefined",
                          "desc": "The type of the test, used to denote whether this is a suite."
                        }
                      ]
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`testNumber` {number} The ordinal number of the test.",
                      "name": "testNumber",
                      "type": "number",
                      "desc": "The ordinal number of the test."
                    },
                    {
                      "textRaw": "`todo` {string|boolean|undefined} Present if [`context.todo`][] is called",
                      "name": "todo",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.todo`][] is called"
                    },
                    {
                      "textRaw": "`skip` {string|boolean|undefined} Present if [`context.skip`][] is called",
                      "name": "skip",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.skip`][] is called"
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test completes its execution.\nThis event is not emitted in the same order as the tests are\ndefined.\nThe corresponding declaration ordered events are <code>'test:pass'</code> and <code>'test:fail'</code>.</p>"
            },
            {
              "textRaw": "Event: `'test:dequeue'`",
              "type": "event",
              "name": "test:dequeue",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`type` {string} The test type. Either `'suite'` or `'test'`.",
                      "name": "type",
                      "type": "string",
                      "desc": "The test type. Either `'suite'` or `'test'`."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test is dequeued, right before it is executed.\nThis event is not guaranteed to be emitted in the same order as the tests are\ndefined. The corresponding declaration ordered event is <code>'test:start'</code>.</p>"
            },
            {
              "textRaw": "Event: `'test:diagnostic'`",
              "type": "event",
              "name": "test:diagnostic",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`message` {string} The diagnostic message.",
                      "name": "message",
                      "type": "string",
                      "desc": "The diagnostic message."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when <a href=\"#contextdiagnosticmessage\"><code>context.diagnostic</code></a> is called.\nThis event is guaranteed to be emitted in the same order as the tests are\ndefined.</p>"
            },
            {
              "textRaw": "Event: `'test:enqueue'`",
              "type": "event",
              "name": "test:enqueue",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`type` {string} The test type. Either `'suite'` or `'test'`.",
                      "name": "type",
                      "type": "string",
                      "desc": "The test type. Either `'suite'` or `'test'`."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test is enqueued for execution.</p>"
            },
            {
              "textRaw": "Event: `'test:fail'`",
              "type": "event",
              "name": "test:fail",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`details` {Object} Additional execution metadata.",
                      "name": "details",
                      "type": "Object",
                      "desc": "Additional execution metadata.",
                      "options": [
                        {
                          "textRaw": "`duration_ms` {number} The duration of the test in milliseconds.",
                          "name": "duration_ms",
                          "type": "number",
                          "desc": "The duration of the test in milliseconds."
                        },
                        {
                          "textRaw": "`error` {Error} An error wrapping the error thrown by the test.",
                          "name": "error",
                          "type": "Error",
                          "desc": "An error wrapping the error thrown by the test.",
                          "options": [
                            {
                              "textRaw": "`cause` {Error} The actual error thrown by the test.",
                              "name": "cause",
                              "type": "Error",
                              "desc": "The actual error thrown by the test."
                            }
                          ]
                        },
                        {
                          "textRaw": "`type` {string|undefined} The type of the test, used to denote whether this is a suite.",
                          "name": "type",
                          "type": "string|undefined",
                          "desc": "The type of the test, used to denote whether this is a suite."
                        }
                      ]
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`testNumber` {number} The ordinal number of the test.",
                      "name": "testNumber",
                      "type": "number",
                      "desc": "The ordinal number of the test."
                    },
                    {
                      "textRaw": "`todo` {string|boolean|undefined} Present if [`context.todo`][] is called",
                      "name": "todo",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.todo`][] is called"
                    },
                    {
                      "textRaw": "`skip` {string|boolean|undefined} Present if [`context.skip`][] is called",
                      "name": "skip",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.skip`][] is called"
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test fails.\nThis event is guaranteed to be emitted in the same order as the tests are\ndefined.\nThe corresponding execution ordered event is <code>'test:complete'</code>.</p>"
            },
            {
              "textRaw": "Event: `'test:pass'`",
              "type": "event",
              "name": "test:pass",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`details` {Object} Additional execution metadata.",
                      "name": "details",
                      "type": "Object",
                      "desc": "Additional execution metadata.",
                      "options": [
                        {
                          "textRaw": "`duration_ms` {number} The duration of the test in milliseconds.",
                          "name": "duration_ms",
                          "type": "number",
                          "desc": "The duration of the test in milliseconds."
                        },
                        {
                          "textRaw": "`type` {string|undefined} The type of the test, used to denote whether this is a suite.",
                          "name": "type",
                          "type": "string|undefined",
                          "desc": "The type of the test, used to denote whether this is a suite."
                        }
                      ]
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`testNumber` {number} The ordinal number of the test.",
                      "name": "testNumber",
                      "type": "number",
                      "desc": "The ordinal number of the test."
                    },
                    {
                      "textRaw": "`todo` {string|boolean|undefined} Present if [`context.todo`][] is called",
                      "name": "todo",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.todo`][] is called"
                    },
                    {
                      "textRaw": "`skip` {string|boolean|undefined} Present if [`context.skip`][] is called",
                      "name": "skip",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.skip`][] is called"
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test passes.\nThis event is guaranteed to be emitted in the same order as the tests are\ndefined.\nThe corresponding execution ordered event is <code>'test:complete'</code>.</p>"
            },
            {
              "textRaw": "Event: `'test:plan'`",
              "type": "event",
              "name": "test:plan",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`count` {number} The number of subtests that have ran.",
                      "name": "count",
                      "type": "number",
                      "desc": "The number of subtests that have ran."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when all subtests have completed for a given test.\nThis event is guaranteed to be emitted in the same order as the tests are\ndefined.</p>"
            },
            {
              "textRaw": "Event: `'test:start'`",
              "type": "event",
              "name": "test:start",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`column` {number|undefined} The column number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "column",
                      "type": "number|undefined",
                      "desc": "The column number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, `undefined` if test was run through the REPL.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, `undefined` if test was run through the REPL."
                    },
                    {
                      "textRaw": "`line` {number|undefined} The line number where the test is defined, or `undefined` if the test was run through the REPL.",
                      "name": "line",
                      "type": "number|undefined",
                      "desc": "The line number where the test is defined, or `undefined` if the test was run through the REPL."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test starts reporting its own and its subtests status.\nThis event is guaranteed to be emitted in the same order as the tests are\ndefined.\nThe corresponding execution ordered event is <code>'test:dequeue'</code>.</p>"
            },
            {
              "textRaw": "Event: `'test:stderr'`",
              "type": "event",
              "name": "test:stderr",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`file` {string} The path of the test file.",
                      "name": "file",
                      "type": "string",
                      "desc": "The path of the test file."
                    },
                    {
                      "textRaw": "`message` {string} The message written to `stderr`.",
                      "name": "message",
                      "type": "string",
                      "desc": "The message written to `stderr`."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a running test writes to <code>stderr</code>.\nThis event is only emitted if <code>--test</code> flag is passed.\nThis event is not guaranteed to be emitted in the same order as the tests are\ndefined.</p>"
            },
            {
              "textRaw": "Event: `'test:stdout'`",
              "type": "event",
              "name": "test:stdout",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`file` {string} The path of the test file.",
                      "name": "file",
                      "type": "string",
                      "desc": "The path of the test file."
                    },
                    {
                      "textRaw": "`message` {string} The message written to `stdout`.",
                      "name": "message",
                      "type": "string",
                      "desc": "The message written to `stdout`."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a running test writes to <code>stdout</code>.\nThis event is only emitted if <code>--test</code> flag is passed.\nThis event is not guaranteed to be emitted in the same order as the tests are\ndefined.</p>"
            },
            {
              "textRaw": "Event: `'test:summary'`",
              "type": "event",
              "name": "test:summary",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`counts` {Object} An object containing the counts of various test results.",
                      "name": "counts",
                      "type": "Object",
                      "desc": "An object containing the counts of various test results.",
                      "options": [
                        {
                          "textRaw": "`cancelled` {number} The total number of cancelled tests.",
                          "name": "cancelled",
                          "type": "number",
                          "desc": "The total number of cancelled tests."
                        },
                        {
                          "textRaw": "`failed` {number} The total number of failed tests.",
                          "name": "failed",
                          "type": "number",
                          "desc": "The total number of failed tests."
                        },
                        {
                          "textRaw": "`passed` {number} The total number of passed tests.",
                          "name": "passed",
                          "type": "number",
                          "desc": "The total number of passed tests."
                        },
                        {
                          "textRaw": "`skipped` {number} The total number of skipped tests.",
                          "name": "skipped",
                          "type": "number",
                          "desc": "The total number of skipped tests."
                        },
                        {
                          "textRaw": "`suites` {number} The total number of suites run.",
                          "name": "suites",
                          "type": "number",
                          "desc": "The total number of suites run."
                        },
                        {
                          "textRaw": "`tests` {number} The total number of tests run, excluding suites.",
                          "name": "tests",
                          "type": "number",
                          "desc": "The total number of tests run, excluding suites."
                        },
                        {
                          "textRaw": "`todo` {number} The total number of TODO tests.",
                          "name": "todo",
                          "type": "number",
                          "desc": "The total number of TODO tests."
                        },
                        {
                          "textRaw": "`topLevel` {number} The total number of top level tests and suites.",
                          "name": "topLevel",
                          "type": "number",
                          "desc": "The total number of top level tests and suites."
                        }
                      ]
                    },
                    {
                      "textRaw": "`duration_ms` {number} The duration of the test run in milliseconds.",
                      "name": "duration_ms",
                      "type": "number",
                      "desc": "The duration of the test run in milliseconds."
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file that generated the summary. If the summary corresponds to multiple files, this value is `undefined`.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file that generated the summary. If the summary corresponds to multiple files, this value is `undefined`."
                    },
                    {
                      "textRaw": "`success` {boolean} Indicates whether or not the test run is considered successful or not. If any error condition occurs, such as a failing test or unmet coverage threshold, this value will be set to `false`.",
                      "name": "success",
                      "type": "boolean",
                      "desc": "Indicates whether or not the test run is considered successful or not. If any error condition occurs, such as a failing test or unmet coverage threshold, this value will be set to `false`."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test run completes. This event contains metrics pertaining to\nthe completed test run, and is useful for determining if a test run passed or\nfailed. If process-level test isolation is used, a <code>'test:summary'</code> event is\ngenerated for each test file in addition to a final cumulative summary.</p>"
            },
            {
              "textRaw": "Event: `'test:watch:drained'`",
              "type": "event",
              "name": "test:watch:drained",
              "params": [],
              "desc": "<p>Emitted when no more tests are queued for execution in watch mode.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `TestContext`",
          "type": "class",
          "name": "TestContext",
          "meta": {
            "added": [
              "v18.0.0",
              "v16.17.0"
            ],
            "changes": [
              {
                "version": [
                  "v20.1.0",
                  "v18.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/47586",
                "description": "The `before` function was added to TestContext."
              }
            ]
          },
          "desc": "<p>An instance of <code>TestContext</code> is passed to each test function in order to\ninteract with the test runner. However, the <code>TestContext</code> constructor is not\nexposed as part of the API.</p>",
          "methods": [
            {
              "textRaw": "`context.before([fn][, options])`",
              "type": "method",
              "name": "before",
              "meta": {
                "added": [
                  "v20.1.0",
                  "v18.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the hook. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress hook."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook running before\nsubtest of the current test.</p>"
            },
            {
              "textRaw": "`context.beforeEach([fn][, options])`",
              "type": "method",
              "name": "beforeEach",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the hook. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress hook."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook running\nbefore each subtest of the current test.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  t.beforeEach((t) => t.diagnostic(`about to run ${t.name}`));\n  await t.test(\n    'This is a subtest',\n    (t) => {\n      assert.ok('some relevant assertion here');\n    },\n  );\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.after([fn][, options])`",
              "type": "method",
              "name": "after",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the hook. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress hook."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook that runs after the current test\nfinishes.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  t.after((t) => t.diagnostic(`finished running ${t.name}`));\n  assert.ok('some relevant assertion here');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.afterEach([fn][, options])`",
              "type": "method",
              "name": "afterEach",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the hook. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress hook."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook running\nafter each subtest of the current test.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  t.afterEach((t) => t.diagnostic(`finished running ${t.name}`));\n  await t.test(\n    'This is a subtest',\n    (t) => {\n      assert.ok('some relevant assertion here');\n    },\n  );\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.diagnostic(message)`",
              "type": "method",
              "name": "diagnostic",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {string} Message to be reported.",
                      "name": "message",
                      "type": "string",
                      "desc": "Message to be reported."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to write diagnostics to the output. Any diagnostic\ninformation is included at the end of the test's results. This function does\nnot return a value.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  t.diagnostic('A diagnostic message');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.plan(count)`",
              "type": "method",
              "name": "plan",
              "meta": {
                "added": [
                  "v22.2.0",
                  "v20.15.0"
                ],
                "changes": [
                  {
                    "version": "v23.4.0",
                    "pr-url": "https://github.com/nodejs/node/pull/55895",
                    "description": "This function is no longer experimental."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`count` {number} The number of assertions and subtests that are expected to run.",
                      "name": "count",
                      "type": "number",
                      "desc": "The number of assertions and subtests that are expected to run."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to set the number of assertions and subtests that are expected to run\nwithin the test. If the number of assertions and subtests that run does not match the\nexpected count, the test will fail.</p>\n<blockquote>\n<p>Note: To make sure assertions are tracked, <code>t.assert</code> must be used instead of <code>assert</code> directly.</p>\n</blockquote>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  t.plan(2);\n  t.assert.ok('some relevant assertion here');\n  t.test('subtest', () => {});\n});\n</code></pre>\n<p>When working with asynchronous code, the <code>plan</code> function can be used to ensure that the\ncorrect number of assertions are run:</p>\n<pre><code class=\"language-js\">test('planning with streams', (t, done) => {\n  function* generate() {\n    yield 'a';\n    yield 'b';\n    yield 'c';\n  }\n  const expected = ['a', 'b', 'c'];\n  t.plan(expected.length);\n  const stream = Readable.from(generate());\n  stream.on('data', (chunk) => {\n    t.assert.strictEqual(chunk, expected.shift());\n  });\n\n  stream.on('end', () => {\n    done();\n  });\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.runOnly(shouldRunOnlyTests)`",
              "type": "method",
              "name": "runOnly",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`shouldRunOnlyTests` {boolean} Whether or not to run `only` tests.",
                      "name": "shouldRunOnlyTests",
                      "type": "boolean",
                      "desc": "Whether or not to run `only` tests."
                    }
                  ]
                }
              ],
              "desc": "<p>If <code>shouldRunOnlyTests</code> is truthy, the test context will only run tests that\nhave the <code>only</code> option set. Otherwise, all tests are run. If Node.js was not\nstarted with the <a href=\"cli.html#--test-only\"><code>--test-only</code></a> command-line option, this function is a\nno-op.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  // The test context can be set to run subtests with the 'only' option.\n  t.runOnly(true);\n  return Promise.all([\n    t.test('this subtest is now skipped'),\n    t.test('this subtest is run', { only: true }),\n  ]);\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.skip([message])`",
              "type": "method",
              "name": "skip",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {string} Optional skip message.",
                      "name": "message",
                      "type": "string",
                      "desc": "Optional skip message."
                    }
                  ]
                }
              ],
              "desc": "<p>This function causes the test's output to indicate the test as skipped. If\n<code>message</code> is provided, it is included in the output. Calling <code>skip()</code> does\nnot terminate execution of the test function. This function does not return a\nvalue.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  // Make sure to return here as well if the test contains additional logic.\n  t.skip('this is skipped');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.todo([message])`",
              "type": "method",
              "name": "todo",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {string} Optional `TODO` message.",
                      "name": "message",
                      "type": "string",
                      "desc": "Optional `TODO` message."
                    }
                  ]
                }
              ],
              "desc": "<p>This function adds a <code>TODO</code> directive to the test's output. If <code>message</code> is\nprovided, it is included in the output. Calling <code>todo()</code> does not terminate\nexecution of the test function. This function does not return a value.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  // This test is marked as `TODO`\n  t.todo('this is a todo');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.test([name][, options][, fn])`",
              "type": "method",
              "name": "test",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v18.8.0",
                      "v16.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/43554",
                    "description": "Add a `signal` option."
                  },
                  {
                    "version": [
                      "v18.7.0",
                      "v16.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/43505",
                    "description": "Add a `timeout` option."
                  }
                ]
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Promise} Fulfilled with `undefined` once the test completes.",
                    "name": "return",
                    "type": "Promise",
                    "desc": "Fulfilled with `undefined` once the test completes."
                  },
                  "params": [
                    {
                      "textRaw": "`name` {string} The name of the subtest, which is displayed when reporting test results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.",
                      "name": "name",
                      "type": "string",
                      "default": "The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name",
                      "desc": "The name of the subtest, which is displayed when reporting test results."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the subtest. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the subtest. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`concurrency` {number|boolean|null} If a number is provided, then that many tests would run in parallel within the application thread. If `true`, it would run all subtests in parallel. If `false`, it would only run one test at a time. If unspecified, subtests inherit this value from their parent. **Default:** `null`.",
                          "name": "concurrency",
                          "type": "number|boolean|null",
                          "default": "`null`",
                          "desc": "If a number is provided, then that many tests would run in parallel within the application thread. If `true`, it would run all subtests in parallel. If `false`, it would only run one test at a time. If unspecified, subtests inherit this value from their parent."
                        },
                        {
                          "textRaw": "`only` {boolean} If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped. **Default:** `false`.",
                          "name": "only",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress test.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress test."
                        },
                        {
                          "textRaw": "`skip` {boolean|string} If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test. **Default:** `false`.",
                          "name": "skip",
                          "type": "boolean|string",
                          "default": "`false`",
                          "desc": "If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test."
                        },
                        {
                          "textRaw": "`todo` {boolean|string} If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`. **Default:** `false`.",
                          "name": "todo",
                          "type": "boolean|string",
                          "default": "`false`",
                          "desc": "If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent."
                        },
                        {
                          "textRaw": "`plan` {number} The number of assertions and subtests expected to be run in the test. If the number of assertions run in the test does not match the number specified in the plan, the test will fail. **Default:** `undefined`.",
                          "name": "plan",
                          "type": "number",
                          "default": "`undefined`",
                          "desc": "The number of assertions and subtests expected to be run in the test. If the number of assertions run in the test does not match the number specified in the plan, the test will fail."
                        }
                      ]
                    },
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create subtests under the current test. This function\nbehaves in the same fashion as the top level <a href=\"#testname-options-fn\"><code>test()</code></a> function.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  await t.test(\n    'This is a subtest',\n    { only: false, skip: false, concurrency: 1, todo: false, plan: 1 },\n    (t) => {\n      t.assert.ok('some relevant assertion here');\n    },\n  );\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.waitFor(condition[, options])`",
              "type": "method",
              "name": "waitFor",
              "meta": {
                "added": [
                  "v23.7.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Promise} Fulfilled with the value returned by `condition`.",
                    "name": "return",
                    "type": "Promise",
                    "desc": "Fulfilled with the value returned by `condition`."
                  },
                  "params": [
                    {
                      "textRaw": "`condition` {Function|AsyncFunction} An assertion function that is invoked periodically until it completes successfully or the defined polling timeout elapses. Successful completion is defined as not throwing or rejecting. This function does not accept any arguments, and is allowed to return any value.",
                      "name": "condition",
                      "type": "Function|AsyncFunction",
                      "desc": "An assertion function that is invoked periodically until it completes successfully or the defined polling timeout elapses. Successful completion is defined as not throwing or rejecting. This function does not accept any arguments, and is allowed to return any value."
                    },
                    {
                      "textRaw": "`options` {Object} An optional configuration object for the polling operation. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "An optional configuration object for the polling operation. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`interval` {number} The number of milliseconds to wait after an unsuccessful invocation of `condition` before trying again. **Default:** `50`.",
                          "name": "interval",
                          "type": "number",
                          "default": "`50`",
                          "desc": "The number of milliseconds to wait after an unsuccessful invocation of `condition` before trying again."
                        },
                        {
                          "textRaw": "`timeout` {number} The poll timeout in milliseconds. If `condition` has not succeeded by the time this elapses, an error occurs. **Default:** `1000`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`1000`",
                          "desc": "The poll timeout in milliseconds. If `condition` has not succeeded by the time this elapses, an error occurs."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This method polls a <code>condition</code> function until that function either returns\nsuccessfully or the operation times out.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "`context.assert`",
              "name": "assert",
              "meta": {
                "added": [
                  "v22.2.0",
                  "v20.15.0"
                ],
                "changes": []
              },
              "desc": "<p>An object containing assertion methods bound to <code>context</code>. The top-level\nfunctions from the <code>node:assert</code> module are exposed here for the purpose of\ncreating test plans.</p>\n<pre><code class=\"language-js\">test('test', (t) => {\n  t.plan(1);\n  t.assert.strictEqual(true, true);\n});\n</code></pre>",
              "methods": [
                {
                  "textRaw": "`context.assert.fileSnapshot(value, path[, options])`",
                  "type": "method",
                  "name": "fileSnapshot",
                  "meta": {
                    "added": [
                      "v23.7.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`value` {any} A value to serialize to a string. If Node.js was started with the [`--test-update-snapshots`][] flag, the serialized value is written to `path`. Otherwise, the serialized value is compared to the contents of the existing snapshot file.",
                          "name": "value",
                          "type": "any",
                          "desc": "A value to serialize to a string. If Node.js was started with the [`--test-update-snapshots`][] flag, the serialized value is written to `path`. Otherwise, the serialized value is compared to the contents of the existing snapshot file."
                        },
                        {
                          "textRaw": "`path` {string} The file where the serialized `value` is written.",
                          "name": "path",
                          "type": "string",
                          "desc": "The file where the serialized `value` is written."
                        },
                        {
                          "textRaw": "`options` {Object} Optional configuration options. The following properties are supported:",
                          "name": "options",
                          "type": "Object",
                          "desc": "Optional configuration options. The following properties are supported:",
                          "options": [
                            {
                              "textRaw": "`serializers` {Array} An array of synchronous functions used to serialize `value` into a string. `value` is passed as the only argument to the first serializer function. The return value of each serializer is passed as input to the next serializer. Once all serializers have run, the resulting value is coerced to a string. **Default:** If no serializers are provided, the test runner's default serializers are used.",
                              "name": "serializers",
                              "type": "Array",
                              "default": "If no serializers are provided, the test runner's default serializers are used",
                              "desc": "An array of synchronous functions used to serialize `value` into a string. `value` is passed as the only argument to the first serializer function. The return value of each serializer is passed as input to the next serializer. Once all serializers have run, the resulting value is coerced to a string."
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This function serializes <code>value</code> and writes it to the file specified by <code>path</code>.</p>\n<pre><code class=\"language-js\">test('snapshot test with default serialization', (t) => {\n  t.assert.fileSnapshot({ value1: 1, value2: 2 }, './snapshots/snapshot.json');\n});\n</code></pre>\n<p>This function differs from <code>context.assert.snapshot()</code> in the following ways:</p>\n<ul>\n<li>The snapshot file path is explicitly provided by the user.</li>\n<li>Each snapshot file is limited to a single snapshot value.</li>\n<li>No additional escaping is performed by the test runner.</li>\n</ul>\n<p>These differences allow snapshot files to better support features such as syntax\nhighlighting.</p>"
                },
                {
                  "textRaw": "`context.assert.snapshot(value[, options])`",
                  "type": "method",
                  "name": "snapshot",
                  "meta": {
                    "added": [
                      "v22.3.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`value` {any} A value to serialize to a string. If Node.js was started with the [`--test-update-snapshots`][] flag, the serialized value is written to the snapshot file. Otherwise, the serialized value is compared to the corresponding value in the existing snapshot file.",
                          "name": "value",
                          "type": "any",
                          "desc": "A value to serialize to a string. If Node.js was started with the [`--test-update-snapshots`][] flag, the serialized value is written to the snapshot file. Otherwise, the serialized value is compared to the corresponding value in the existing snapshot file."
                        },
                        {
                          "textRaw": "`options` {Object} Optional configuration options. The following properties are supported:",
                          "name": "options",
                          "type": "Object",
                          "desc": "Optional configuration options. The following properties are supported:",
                          "options": [
                            {
                              "textRaw": "`serializers` {Array} An array of synchronous functions used to serialize `value` into a string. `value` is passed as the only argument to the first serializer function. The return value of each serializer is passed as input to the next serializer. Once all serializers have run, the resulting value is coerced to a string. **Default:** If no serializers are provided, the test runner's default serializers are used.",
                              "name": "serializers",
                              "type": "Array",
                              "default": "If no serializers are provided, the test runner's default serializers are used",
                              "desc": "An array of synchronous functions used to serialize `value` into a string. `value` is passed as the only argument to the first serializer function. The return value of each serializer is passed as input to the next serializer. Once all serializers have run, the resulting value is coerced to a string."
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This function implements assertions for snapshot testing.</p>\n<pre><code class=\"language-js\">test('snapshot test with default serialization', (t) => {\n  t.assert.snapshot({ value1: 1, value2: 2 });\n});\n\ntest('snapshot test with custom serialization', (t) => {\n  t.assert.snapshot({ value3: 3, value4: 4 }, {\n    serializers: [(value) => JSON.stringify(value)],\n  });\n});\n</code></pre>"
                }
              ]
            },
            {
              "textRaw": "`context.filePath`",
              "name": "filePath",
              "meta": {
                "added": [
                  "v22.6.0",
                  "v20.16.0"
                ],
                "changes": []
              },
              "desc": "<p>The absolute path of the test file that created the current test. If a test file\nimports additional modules that generate tests, the imported tests will return\nthe path of the root test file.</p>"
            },
            {
              "textRaw": "`context.fullName`",
              "name": "fullName",
              "meta": {
                "added": [
                  "v22.3.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the test and each of its ancestors, separated by <code>></code>.</p>"
            },
            {
              "textRaw": "`context.name`",
              "name": "name",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the test.</p>"
            },
            {
              "textRaw": "`signal` Type: {AbortSignal}",
              "type": "AbortSignal",
              "name": "Type",
              "meta": {
                "added": [
                  "v18.7.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "desc": "<p>Can be used to abort test subtasks when the test has been aborted.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  await fetch('some/uri', { signal: t.signal });\n});\n</code></pre>"
            }
          ]
        },
        {
          "textRaw": "Class: `SuiteContext`",
          "type": "class",
          "name": "SuiteContext",
          "meta": {
            "added": [
              "v18.7.0",
              "v16.17.0"
            ],
            "changes": []
          },
          "desc": "<p>An instance of <code>SuiteContext</code> is passed to each suite function in order to\ninteract with the test runner. However, the <code>SuiteContext</code> constructor is not\nexposed as part of the API.</p>",
          "properties": [
            {
              "textRaw": "`context.filePath`",
              "name": "filePath",
              "meta": {
                "added": [
                  "v22.6.0"
                ],
                "changes": []
              },
              "desc": "<p>The absolute path of the test file that created the current suite. If a test\nfile imports additional modules that generate suites, the imported suites will\nreturn the path of the root test file.</p>"
            },
            {
              "textRaw": "`context.name`",
              "name": "name",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the suite.</p>"
            },
            {
              "textRaw": "`signal` Type: {AbortSignal}",
              "type": "AbortSignal",
              "name": "Type",
              "meta": {
                "added": [
                  "v18.7.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "desc": "<p>Can be used to abort test subtasks when the test has been aborted.</p>"
            }
          ]
        }
      ],
      "type": "module",
      "displayName": "Test runner"
    }
  ]
}