{
  "type": "module",
  "source": "doc/api/test.md",
  "modules": [
    {
      "textRaw": "Test runner",
      "name": "test_runner",
      "introduced_in": "v18.0.0",
      "type": "module",
      "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>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",
          "type": "module",
          "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>",
          "displayName": "Subtests"
        },
        {
          "textRaw": "Rerunning failed tests",
          "name": "rerunning_failed_tests",
          "type": "module",
          "desc": "<p>The test runner supports persisting the state of the run to a file, allowing\nthe test runner to rerun failed tests without having to re-run the entire test suite.\nUse the <a href=\"cli.html#--test-rerun-failures\"><code>--test-rerun-failures</code></a> command-line option to specify a file path where the\nstate of the run is stored. if the state file does not exist, the test runner will\ncreate it.\nthe state file is a JSON file that contains an array of run attempts.\nEach run attempt is an object mapping successful tests to the attempt they have passed in.\nThe key identifying a test in this map is the test file path, with the line and column where the test is defined.\nin a case where a test defined in a specific location is run multiple times,\nfor example within a function or a loop,\na counter will be appended to the key, to disambiguate the test runs.\nnote changing the order of test execution or the location of a test can lead the test runner\nto consider tests as passed on a previous attempt,\nmeaning <code>--test-rerun-failures</code> should be used when tests run in a deterministic order.</p>\n<p>example of a state file:</p>\n<pre><code class=\"language-json\">[\n  {\n    \"test.js:10:5\": { \"passed_on_attempt\": 0, \"name\": \"test 1\" }\n  },\n  {\n    \"test.js:10:5\": { \"passed_on_attempt\": 0, \"name\": \"test 1\" },\n    \"test.js:20:5\": { \"passed_on_attempt\": 1, \"name\": \"test 2\" }\n  }\n]\n</code></pre>\n<p>in this example, there are two run attempts, with two tests defined in <code>test.js</code>,\nthe first test succeeded on the first attempt, and the second test succeeded on the second attempt.</p>\n<p>When the <code>--test-rerun-failures</code> option is used, the test runner will only run tests that have not yet passed.</p>\n<pre><code class=\"language-bash\">node --test-rerun-failures /path/to/state/file\n</code></pre>",
          "displayName": "Rerunning failed tests"
        },
        {
          "textRaw": "`describe()` and `it()` aliases",
          "name": "`describe()`_and_`it()`_aliases",
          "type": "module",
          "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>",
          "displayName": "`describe()` and `it()` aliases"
        },
        {
          "textRaw": "Skipping tests",
          "name": "skipping_tests",
          "type": "module",
          "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>",
          "displayName": "Skipping tests"
        },
        {
          "textRaw": "TODO tests",
          "name": "todo_tests",
          "type": "module",
          "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>",
          "displayName": "TODO tests"
        },
        {
          "textRaw": "Expecting tests to fail",
          "name": "expecting_tests_to_fail",
          "type": "module",
          "meta": {
            "added": [
              "v25.5.0",
              "v24.14.0"
            ],
            "changes": []
          },
          "desc": "<p>This flips the pass/fail reporting for a specific test or suite: a flagged test\ncase must throw in order to pass, and a flagged test case that does not throw\nfails.</p>\n<p>In each of the following, <code>doTheThing()</code> fails to return <code>true</code>, but since the\ntests are flagged <code>expectFailure</code>, they pass.</p>\n<pre><code class=\"language-js\">it.expectFailure('should do the thing', () => {\n  assert.strictEqual(doTheThing(), true);\n});\n\nit('should do the thing', { expectFailure: true }, () => {\n  assert.strictEqual(doTheThing(), true);\n});\n\nit('should do the thing', { expectFailure: 'feature not implemented' }, () => {\n  assert.strictEqual(doTheThing(), true);\n});\n</code></pre>\n<p>If the value of <code>expectFailure</code> is a <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp\"><code>&#x3C;RegExp></code></a> | <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function\"><code>&#x3C;Function></code></a> | <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> | <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error\"><code>&#x3C;Error></code></a>\nthe tests will pass only if they throw a matching value.\nSee <a href=\"assert.html#assertthrowsfn-error-message\"><code>assert.throws</code></a> for how each value type is handled.</p>\n<p>Each of the following tests fails <em>despite</em> being flagged <code>expectFailure</code>\nbecause the failure does not match the specific <strong>expected</strong> failure.</p>\n<pre><code class=\"language-js\">it('fails because regex does not match', {\n  expectFailure: /expected message/,\n}, () => {\n  throw new Error('different message');\n});\n\nit('fails because object matcher does not match', {\n  expectFailure: { code: 'ERR_EXPECTED' },\n}, () => {\n  const err = new Error('boom');\n  err.code = 'ERR_ACTUAL';\n  throw err;\n});\n</code></pre>\n<p>To supply both a reason and specific error for <code>expectFailure</code>, use <code>{ label, match }</code>.</p>\n<pre><code class=\"language-js\">it('should fail with specific error and reason', {\n  expectFailure: {\n    label: 'reason for failure',\n    match: /error message/,\n  },\n}, () => {\n  assert.strictEqual(doTheThing(), true);\n});\n</code></pre>\n<p><code>skip</code> and/or <code>todo</code> are mutually exclusive to <code>expectFailure</code>, and <code>skip</code> or <code>todo</code>\nwill \"win\" when both are applied (<code>skip</code> wins against both, and <code>todo</code> wins\nagainst <code>expectFailure</code>).</p>\n<p>These tests will be skipped (and not run):</p>\n<pre><code class=\"language-js\">it.expectFailure('should do the thing', { skip: true }, () => {\n  assert.strictEqual(doTheThing(), true);\n});\n\nit.skip('should do the thing', { expectFailure: true }, () => {\n  assert.strictEqual(doTheThing(), true);\n});\n</code></pre>\n<p>These tests will be marked \"todo\" (silencing errors):</p>\n<pre><code class=\"language-js\">it.expectFailure('should do the thing', { todo: true }, () => {\n  assert.strictEqual(doTheThing(), true);\n});\n\nit.todo('should do the thing', { expectFailure: true }, () => {\n  assert.strictEqual(doTheThing(), true);\n});\n</code></pre>",
          "displayName": "Expecting tests to fail"
        },
        {
          "textRaw": "`only` tests",
          "name": "`only`_tests",
          "type": "module",
          "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>",
          "displayName": "`only` tests"
        },
        {
          "textRaw": "Filtering tests by name",
          "name": "filtering_tests_by_name",
          "type": "module",
          "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>",
          "displayName": "Filtering tests by name"
        },
        {
          "textRaw": "Test tags",
          "name": "test_tags",
          "type": "module",
          "meta": {
            "added": [
              "v26.2.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": "Early development",
          "desc": "<p>Tags annotate tests and suites with arbitrary string labels. The\n<a href=\"cli.html#--experimental-test-tag-filterexpr\"><code>--experimental-test-tag-filter</code></a> CLI flag (or the <code>testTagFilters</code>\noption on <a href=\"#runoptions\"><code>run()</code></a>) selects tests whose tag set contains every\nprovided filter value.</p>\n<p>Tags are an alternative to encoding metadata into test names. They are\nuseful for cross-cutting axes such as subsystem, speed bucket, flakiness,\nor environment, where a name pattern would be brittle.</p>",
          "modules": [
            {
              "textRaw": "Authoring tagged tests",
              "name": "authoring_tagged_tests",
              "type": "module",
              "desc": "<p>Pass a <code>tags</code> array on any of <code>test()</code>, <code>it()</code>, <code>suite()</code>, or <code>describe()</code>.\nTags inherit from a suite to its child tests by union—a test inside a\nsuite tagged <code>['db']</code> that declares its own <code>tags: ['integration']</code>\neffectively has both tags.</p>\n<pre><code class=\"language-mjs\">import { describe, it } from 'node:test';\n\ndescribe('database', { tags: ['db'] }, () => {\n  it('reads a row');                                            // tags: ['db']\n  it('writes a row', { tags: ['integration'] });                // tags: ['db', 'integration']\n  it('reconnects after disconnect', { tags: ['flaky'] });       // tags: ['db', 'flaky']\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const { describe, it } = require('node:test');\n\ndescribe('database', { tags: ['db'] }, () => {\n  it('reads a row');                                            // tags: ['db']\n  it('writes a row', { tags: ['integration'] });                // tags: ['db', 'integration']\n  it('reconnects after disconnect', { tags: ['flaky'] });       // tags: ['db', 'flaky']\n});\n</code></pre>\n<p>Tag values must be non-empty strings. Tags are matched case-insensitively;\nthe canonical form is lowercase. Duplicates within a single <code>tags</code> array\nare collapsed on the lowercased form, preserving the first-seen\ndeclaration order.</p>\n<p>Hooks (<code>before</code>, <code>after</code>, <code>beforeEach</code>, <code>afterEach</code>) do not declare their\nown tags. They run as part of their owning suite, which carries the\nsuite's tags.</p>",
              "displayName": "Authoring tagged tests"
            },
            {
              "textRaw": "Filtering by tag",
              "name": "filtering_by_tag",
              "type": "module",
              "desc": "<p>Each <a href=\"cli.html#--experimental-test-tag-filterexpr\"><code>--experimental-test-tag-filter</code></a> value is a literal tag name. A\ntest runs only when its tag set contains that name. The flag may be\nspecified more than once; tests must match <strong>every</strong> filter to run. The\nsame applies to the <code>testTagFilters</code> array on <a href=\"#runoptions\"><code>run()</code></a>. Filters are\ncase-insensitive and AND'd with <a href=\"cli.html#--test-name-pattern\"><code>--test-name-pattern</code></a>,\n<a href=\"cli.html#--test-skip-pattern\"><code>--test-skip-pattern</code></a>, and <code>.only</code> filtering.</p>\n<p>Untagged tests are excluded under any non-empty filter, since the filter\nrequires the tag to be present.</p>",
              "displayName": "Filtering by tag"
            },
            {
              "textRaw": "Reading tags from inside a test",
              "name": "reading_tags_from_inside_a_test",
              "type": "module",
              "desc": "<p>The <a href=\"#class-testcontext\"><code>TestContext</code></a> object exposes the test's tags as a frozen array\nthrough <a href=\"#contexttags\"><code>context.tags</code></a>, so tests can branch on their own metadata.</p>",
              "displayName": "Reading tags from inside a test"
            },
            {
              "textRaw": "Errors",
              "name": "errors",
              "type": "module",
              "desc": "<p>A tag value that violates the validation rules above throws\n<code>ERR_INVALID_ARG_VALUE</code> at the registration site, before any test runs.\nA non-array <code>tags</code> value throws <code>ERR_INVALID_ARG_TYPE</code>.</p>",
              "displayName": "Errors"
            }
          ],
          "displayName": "Test tags"
        },
        {
          "textRaw": "Extraneous asynchronous activity",
          "name": "extraneous_asynchronous_activity",
          "type": "module",
          "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\"><code>&#x3C;TestsStream></code></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\"><code>&#x3C;TestsStream></code></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>",
          "displayName": "Extraneous asynchronous activity"
        },
        {
          "textRaw": "Watch mode",
          "name": "watch_mode",
          "type": "module",
          "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>",
          "displayName": "Watch mode"
        },
        {
          "textRaw": "Global setup and teardown",
          "name": "global_setup_and_teardown",
          "type": "module",
          "meta": {
            "added": [
              "v24.0.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": "Early development",
          "desc": "<p>The test runner supports specifying a module that will be evaluated before all tests are executed and\ncan be used to setup global state or fixtures for tests. This is useful for preparing resources or setting up\nshared state that is required by multiple tests.</p>\n<p>This module can export any of the following:</p>\n<ul>\n<li>A <code>globalSetup</code> function which runs once before all tests start</li>\n<li>A <code>globalTeardown</code> function which runs once after all tests complete</li>\n</ul>\n<p>The module is specified using the <code>--test-global-setup</code> flag when running tests from the command line.</p>\n<pre><code class=\"language-cjs\">// setup-module.js\nasync function globalSetup() {\n  // Setup shared resources, state, or environment\n  console.log('Global setup executed');\n  // Run servers, create files, prepare databases, etc.\n}\n\nasync function globalTeardown() {\n  // Clean up resources, state, or environment\n  console.log('Global teardown executed');\n  // Close servers, remove files, disconnect from databases, etc.\n}\n\nmodule.exports = { globalSetup, globalTeardown };\n</code></pre>\n<pre><code class=\"language-mjs\">// setup-module.mjs\nexport async function globalSetup() {\n  // Setup shared resources, state, or environment\n  console.log('Global setup executed');\n  // Run servers, create files, prepare databases, etc.\n}\n\nexport async function globalTeardown() {\n  // Clean up resources, state, or environment\n  console.log('Global teardown executed');\n  // Close servers, remove files, disconnect from databases, etc.\n}\n</code></pre>\n<p>If the global setup function throws an error, no tests will be run and the process will exit with a non-zero exit code.\nThe global teardown function will not be called in this case.</p>",
          "displayName": "Global setup and teardown"
        },
        {
          "textRaw": "Running tests from the command line",
          "name": "running_tests_from_the_command_line",
          "type": "module",
          "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-strip-types\"><code>--no-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>",
          "modules": [
            {
              "textRaw": "Randomizing tests execution order",
              "name": "randomizing_tests_execution_order",
              "type": "module",
              "meta": {
                "added": [
                  "v26.1.0"
                ],
                "changes": []
              },
              "stability": 1,
              "stabilityText": "Early development",
              "desc": "<p>The test runner can randomize execution order to help detect\norder-dependent tests. When enabled, the runner randomizes both discovered\ntest files and queued tests within each file. Use <code>--test-randomize</code> to\nenable this mode.</p>\n<pre><code class=\"language-bash\">node --test --test-randomize\n</code></pre>\n<p>When randomization is enabled, the test runner prints the seed used for the run\nas a diagnostic message:</p>\n<pre><code class=\"language-text\">Randomized test order seed: 12345\n</code></pre>\n<p>Use <code>--test-random-seed=&#x3C;number></code> to replay the same randomized order\ndeterministically. Supplying <code>--test-random-seed</code> also enables randomization,\nso <code>--test-randomize</code> is optional when a seed is provided:</p>\n<pre><code class=\"language-bash\">node --test --test-random-seed=12345\n</code></pre>\n<p>In most test files, randomization works automatically. One important exception\nis when subtests are awaited one by one. In that pattern, each subtest starts\nonly after the previous one finishes, so the runner keeps declaration order\ninstead of randomizing it.</p>\n<p>Example: this runs sequentially and is <strong>not</strong> randomized.</p>\n<pre><code class=\"language-mjs\">import test from 'node:test';\n\ntest('math', async (t) => {\n  for (const name of ['adds', 'subtracts', 'multiplies']) {\n    // Sequentially awaiting each subtest preserves declaration order.\n    await t.test(name, async () => {});\n  }\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const test = require('node:test');\n\ntest('math', async (t) => {\n  for (const name of ['adds', 'subtracts', 'multiplies']) {\n    // Sequentially awaiting each subtest preserves declaration order.\n    await t.test(name, async () => {});\n  }\n});\n</code></pre>\n<p>Using suite-style APIs such as <code>describe()</code>/<code>it()</code> or <code>suite()</code>/<code>test()</code>\nstill allows randomization, because sibling tests are enqueued together.</p>\n<p>Example: this remains eligible for randomization.</p>\n<pre><code class=\"language-mjs\">import { describe, it } from 'node:test';\n\ndescribe('math', () => {\n  it('adds', () => {});\n  it('subtracts', () => {});\n  it('multiplies', () => {});\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const { describe, it } = require('node:test');\n\ndescribe('math', () => {\n  it('adds', () => {});\n  it('subtracts', () => {});\n  it('multiplies', () => {});\n});\n</code></pre>\n<p><code>--test-randomize</code> and <code>--test-random-seed</code> are not supported with <code>--watch</code> mode.</p>\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>",
              "displayName": "Randomizing tests execution order"
            },
            {
              "textRaw": "Test runner execution model",
              "name": "test_runner_execution_model",
              "type": "module",
              "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>",
              "modules": [
                {
                  "textRaw": "Child process option inheritance",
                  "name": "child_process_option_inheritance",
                  "type": "module",
                  "desc": "<p>When running tests in process isolation mode (the default), spawned child processes\ninherit Node.js options from the parent process, including those specified in\n<a href=\"cli.html#--experimental-config-filepath---experimental-config-file\">configuration files</a>. However, certain flags are filtered out to enable proper\ntest runner functionality:</p>\n<ul>\n<li><code>--test</code> - Prevented to avoid recursive test execution</li>\n<li><code>--experimental-test-coverage</code> - Managed by the test runner</li>\n<li><code>--experimental-test-tag-filter</code> - Filter values are validated by the parent\nprocess and re-emitted to child processes</li>\n<li><code>--watch</code> - Watch mode is handled at the parent level</li>\n<li><code>--experimental-default-config-file</code> - Config file loading is handled by the parent</li>\n<li><code>--test-reporter</code> - Reporting is managed by the parent process</li>\n<li><code>--test-reporter-destination</code> - Output destinations are controlled by the parent</li>\n<li><code>--experimental-config-file</code> - Config file paths are managed by the parent</li>\n<li><code>--test-randomize</code> - Randomization is managed by the parent process and\npropagated to child processes</li>\n<li><code>--test-random-seed</code> - Randomization seed is managed by the parent process and\npropagated to child processes</li>\n</ul>\n<p>All other Node.js options from command line arguments, environment variables,\nand configuration files are inherited by the child processes.</p>",
                  "displayName": "Child process option inheritance"
                }
              ],
              "displayName": "Test runner execution model"
            }
          ],
          "displayName": "Running tests from the command line"
        },
        {
          "textRaw": "Collecting code coverage",
          "name": "collecting_code_coverage",
          "type": "module",
          "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",
              "type": "module",
              "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>",
              "displayName": "Coverage reporters"
            }
          ],
          "displayName": "Collecting code coverage"
        },
        {
          "textRaw": "Mocking",
          "name": "mocking",
          "type": "module",
          "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\">const 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",
              "type": "module",
              "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>",
              "displayName": "Timers"
            },
            {
              "textRaw": "Dates",
              "name": "dates",
              "type": "module",
              "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 <strong>not</strong> 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>Timers scheduled in the past will <strong>not</strong> run when you call <code>setTime()</code>. To execute those timers, you can use\nthe <code>.tick()</code> method to move forward from the new time.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { test } from 'node:test';\n\ntest('setTime does not execute timers', (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 still not executed\n  assert.strictEqual(fn.mock.callCount(), 0);\n  // Advance in time to execute the timer\n  context.mock.timers.tick(0);\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('setTime does not execute timers', (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 still not executed\n  assert.strictEqual(fn.mock.callCount(), 0);\n  // Advance in time to execute the timer\n  context.mock.timers.tick(0);\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>",
              "displayName": "Dates"
            }
          ],
          "displayName": "Mocking"
        },
        {
          "textRaw": "Snapshot testing",
          "name": "snapshot_testing",
          "type": "module",
          "meta": {
            "added": [
              "v22.3.0"
            ],
            "changes": [
              {
                "version": "v23.4.0",
                "pr-url": "https://github.com/nodejs/node/pull/55897",
                "description": "Snapshot 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>",
          "displayName": "Snapshot testing"
        },
        {
          "textRaw": "Test reporters",
          "name": "test_reporters",
          "type": "module",
          "meta": {
            "added": [
              "v19.6.0",
              "v18.15.0"
            ],
            "changes": [
              {
                "version": "v23.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/54548",
                "description": "The default reporter on non-TTY stdout is changed from `tap` to `spec`, aligning with TTY stdout."
              },
              {
                "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\"><code>&#x3C;TestsStream></code></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",
              "type": "module",
              "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\"><code>&#x3C;TestsStream></code></a></p>\n<p>Example of a custom reporter using <a href=\"stream.html#class-streamtransform\"><code>&#x3C;stream.Transform></code></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:watch:restarted':\n        callback(null, 'test watch restarted due to file change');\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:watch:restarted':\n        callback(null, 'test watch restarted due to file change');\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:watch:restarted':\n        yield 'test watch restarted due to file change\\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:watch:restarted':\n        yield 'test watch restarted due to file change\\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>",
              "displayName": "Custom reporters"
            },
            {
              "textRaw": "Multiple reporters",
              "name": "multiple_reporters",
              "type": "module",
              "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>",
              "displayName": "Multiple reporters"
            }
          ],
          "displayName": "Test reporters"
        },
        {
          "textRaw": "`assert`",
          "name": "`assert`",
          "type": "module",
          "meta": {
            "added": [
              "v23.7.0",
              "v22.14.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)`",
              "name": "register",
              "type": "method",
              "meta": {
                "added": [
                  "v23.7.0",
                  "v22.14.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "name"
                    },
                    {
                      "name": "fn"
                    }
                  ]
                }
              ],
              "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>"
            }
          ],
          "displayName": "`assert`"
        },
        {
          "textRaw": "`snapshot`",
          "name": "`snapshot`",
          "type": "module",
          "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)`",
              "name": "setDefaultSnapshotSerializers",
              "type": "method",
              "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)`",
              "name": "setResolveSnapshotPath",
              "type": "method",
              "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>"
            }
          ],
          "displayName": "`snapshot`"
        },
        {
          "textRaw": "Test instrumentation and OpenTelemetry",
          "name": "test_instrumentation_and_opentelemetry",
          "type": "module",
          "meta": {
            "added": [
              "v26.1.0"
            ],
            "changes": []
          },
          "desc": "<p>The test runner publishes test execution events through the Node.js\n<a href=\"diagnostics_channel.html\"><code>diagnostics_channel</code></a> module, enabling integration with observability tools\nlike OpenTelemetry without requiring changes to the test runner itself.</p>",
          "modules": [
            {
              "textRaw": "Tracing events",
              "name": "tracing_events",
              "type": "module",
              "desc": "<p>The test runner publishes events to the <code>'node.test'</code> tracing channel. Subscribers\ncan use the <a href=\"diagnostics_channel.html#class-tracingchannel\"><code>TracingChannel</code></a> API to bind context or perform custom\ninstrumentation.</p>",
              "modules": [
                {
                  "textRaw": "Channel: `'tracing:node.test:start'`",
                  "name": "channel:_`'tracing:node.test:start'`",
                  "type": "module",
                  "desc": "<ul>\n<li><code>data</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a>\n<ul>\n<li><code>name</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The name of the test.</li>\n<li><code>nesting</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> The nesting level of the test.</li>\n<li><code>file</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> | <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#undefined_type\"><code>&#x3C;undefined></code></a> The path to the test file, or <code>undefined</code> when\nrunning in the REPL.</li>\n<li><code>type</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The type of test. Either <code>'test'</code> or <code>'suite'</code>.</li>\n</ul>\n</li>\n</ul>\n<p>Emitted when a test or suite starts execution. The test's span encompasses all\nof its before, beforeEach, and afterEach hooks, as well as the test body.</p>",
                  "displayName": "Channel: `'tracing:node.test:start'`"
                },
                {
                  "textRaw": "Channel: `'tracing:node.test:end'`",
                  "name": "channel:_`'tracing:node.test:end'`",
                  "type": "module",
                  "desc": "<ul>\n<li><code>data</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a>\n<ul>\n<li><code>name</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The name of the test.</li>\n<li><code>nesting</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> The nesting level of the test.</li>\n<li><code>file</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> | <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#undefined_type\"><code>&#x3C;undefined></code></a> The path to the test file, or <code>undefined</code> when\nrunning in the REPL.</li>\n<li><code>type</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The type of test. Either <code>'test'</code> or <code>'suite'</code>.</li>\n</ul>\n</li>\n</ul>\n<p>Emitted when a test or suite finishes execution.</p>",
                  "displayName": "Channel: `'tracing:node.test:end'`"
                },
                {
                  "textRaw": "Channel: `'tracing:node.test:error'`",
                  "name": "channel:_`'tracing:node.test:error'`",
                  "type": "module",
                  "desc": "<ul>\n<li><code>data</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a>\n<ul>\n<li><code>name</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The name of the test.</li>\n<li><code>nesting</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> The nesting level of the test.</li>\n<li><code>file</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> | <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#undefined_type\"><code>&#x3C;undefined></code></a> The path to the test file, or <code>undefined</code> when\nrunning in the REPL.</li>\n<li><code>type</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The type of test. Either <code>'test'</code> or <code>'suite'</code>.</li>\n<li><code>error</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error\"><code>&#x3C;Error></code></a> The error that was thrown.</li>\n</ul>\n</li>\n</ul>\n<p>Emitted when a test or suite throws an error.</p>",
                  "displayName": "Channel: `'tracing:node.test:error'`"
                }
              ],
              "displayName": "Tracing events"
            },
            {
              "textRaw": "Context propagation with `bindStore()`",
              "name": "context_propagation_with_`bindstore()`",
              "type": "module",
              "desc": "<p>The tracing channel can be used to propagate context through test execution by\nbinding an <code>AsyncLocalStorage</code> instance. This allows context to be automatically\navailable in the test function and all async operations within the test.</p>\n<pre><code class=\"language-mjs\">import dc from 'node:diagnostics_channel';\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nconst testStorage = new AsyncLocalStorage();\nconst testChannel = dc.tracingChannel('node.test');\n\n// Bind context to test execution — the returned value becomes the store\ntestChannel.start.bindStore(testStorage, (data) => {\n  return { testName: data.name, startTime: Date.now() };\n});\n\n// Optionally handle errors and cleanup\ntestChannel.error.subscribe((data) => {\n  const store = testStorage.getStore();\n  console.log(`Test \"${data.name}\" failed after ${Date.now() - store.startTime}ms`);\n});\n\ntestChannel.end.subscribe((data) => {\n  const store = testStorage.getStore();\n  console.log(`Test \"${data.name}\" completed in ${Date.now() - store.startTime}ms`);\n});\n</code></pre>\n<p>When using <code>bindStore()</code>, the context provided will be automatically propagated\nto the test function and all async operations within the test, without requiring\nany additional instrumentation in the test code.</p>",
              "displayName": "Context propagation with `bindStore()`"
            }
          ],
          "displayName": "Test instrumentation and OpenTelemetry"
        }
      ],
      "methods": [
        {
          "textRaw": "`run([options])`",
          "name": "run",
          "type": "method",
          "meta": {
            "added": [
              "v18.9.0",
              "v16.19.0"
            ],
            "changes": [
              {
                "version": "v26.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/63221",
                "description": "Added the `testTagFilters` option."
              },
              {
                "version": [
                  "v25.6.0",
                  "v24.14.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/61367",
                "description": "Add the `env` option."
              },
              {
                "version": "v24.7.0",
                "pr-url": "https://github.com/nodejs/node/pull/59443",
                "description": "Added a rerunFailuresFilePath option."
              },
              {
                "version": "v23.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/54705",
                "description": "Added the `cwd` option."
              },
              {
                "version": [
                  "v23.0.0",
                  "v22.10.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": [
            {
              "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 as if running tests from the command line from that directory. **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 as if running tests from the command line from that directory."
                    },
                    {
                      "textRaw": "`files` {Array} An array containing the list of files to run. **Default:** Same as running tests from the command line.",
                      "name": "files",
                      "type": "Array",
                      "default": "Same as running tests from the command line",
                      "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:** Same as running tests from the command line.",
                      "name": "globPatterns",
                      "type": "Array",
                      "default": "Same as running tests from the command line",
                      "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": "`testTagFilters` {string|string}[] A tag name, or an array of tag names, used to filter tests by their declared tags. Tests must contain every listed tag to run. Equivalent to passing `--experimental-test-tag-filter` on the command line. See Test tags. **Default:** `undefined`.",
                      "name": "testTagFilters",
                      "type": "string|string",
                      "default": "`undefined`",
                      "desc": "[] A tag name, or an array of tag names, used to filter tests by their declared tags. Tests must contain every listed tag to run. Equivalent to passing `--experimental-test-tag-filter` on the command line. See Test tags."
                    },
                    {
                      "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": "`randomize` {boolean} Randomize execution order for test files and queued tests. This option is not supported with `watch: true`. **Default:** `false`.",
                      "name": "randomize",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Randomize execution order for test files and queued tests. This option is not supported with `watch: true`."
                    },
                    {
                      "textRaw": "`randomSeed` {number} Seed used when randomizing execution order. If this option is set, runs can replay the same randomized order deterministically, and setting this option also enables randomization. The value must be an integer between `0` and `4294967295`. **Default:** `undefined`.",
                      "name": "randomSeed",
                      "type": "number",
                      "default": "`undefined`",
                      "desc": "Seed used when randomizing execution order. If this option is set, runs can replay the same randomized order deterministically, and setting this option also enables randomization. The value must be an integer between `0` and `4294967295`."
                    },
                    {
                      "textRaw": "`rerunFailuresFilePath` {string} A file path where the test runner will store the state of the tests to allow rerunning only the failed tests on a next run. see [Rerunning failed tests][] for more information. **Default:** `undefined`.",
                      "name": "rerunFailuresFilePath",
                      "type": "string",
                      "default": "`undefined`",
                      "desc": "A file path where the test runner will store the state of the tests to allow rerunning only the failed tests on a next run. see [Rerunning failed tests][] for more information."
                    },
                    {
                      "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`."
                    },
                    {
                      "textRaw": "`env` {Object} Specify environment variables to be passed along to the test process. This option is not compatible with `isolation='none'`. These variables will override those from the main process, and are not merged with `process.env`. **Default:** `process.env`.",
                      "name": "env",
                      "type": "Object",
                      "default": "`process.env`",
                      "desc": "Specify environment variables to be passed along to the test process. This option is not compatible with `isolation='none'`. These variables will override those from the main process, and are not merged with `process.env`."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {TestsStream}",
                "name": "return",
                "type": "TestsStream"
              }
            }
          ],
          "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])`",
          "name": "suite",
          "type": "method",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "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.",
                  "optional": true
                },
                {
                  "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])`.",
                  "optional": true
                },
                {
                  "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.",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {Promise} Immediately fulfilled with `undefined`.",
                "name": "return",
                "type": "Promise",
                "desc": "Immediately fulfilled with `undefined`."
              }
            }
          ],
          "desc": "<p>The <code>suite()</code> function is imported from the <code>node:test</code> module.</p>"
        },
        {
          "textRaw": "`suite.skip([name][, options][, fn])`",
          "name": "skip",
          "type": "method",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "todo",
          "type": "method",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "only",
          "type": "method",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "test",
          "type": "method",
          "meta": {
            "added": [
              "v18.0.0",
              "v16.17.0"
            ],
            "changes": [
              {
                "version": "v26.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/63221",
                "description": "Added the `tags` option."
              },
              {
                "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": [
            {
              "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.",
                  "optional": true
                },
                {
                  "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 asynchronously (they are still managed by the single-threaded event loop). 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 asynchronously (they are still managed by the single-threaded event loop). 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": "`expectFailure` {boolean|string|RegExp|Function|Object|Error} If truthy, the test is expected to fail. If a non-empty string is provided, that string is displayed in the test results as the reason why the test is expected to fail. If a {RegExp|Function|Object|Error} is provided directly (without wrapping in `{ match: … }`), the test passes only if the thrown error matches, following the behavior of `assert.throws`. To provide both a reason and validation, pass an object with `label` (string) and `match` (RegExp, Function, Object, or Error). **Default:** `false`.",
                      "name": "expectFailure",
                      "type": "boolean|string|RegExp|Function|Object|Error",
                      "default": "`false`",
                      "desc": "If truthy, the test is expected to fail. If a non-empty string is provided, that string is displayed in the test results as the reason why the test is expected to fail. If a {RegExp|Function|Object|Error} is provided directly (without wrapping in `{ match: … }`), the test passes only if the thrown error matches, following the behavior of `assert.throws`. To provide both a reason and validation, pass an object with `label` (string) and `match` (RegExp, Function, Object, or Error)."
                    },
                    {
                      "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": "`tags` {string}[] An array of string labels associated with the test. Used together with `--experimental-test-tag-filter` to filter which tests run. Tags inherit from suites to nested tests by union. See Test tags. **Default:** `[]`.",
                      "name": "tags",
                      "type": "string",
                      "default": "`[]`",
                      "desc": "[] An array of string labels associated with the test. Used together with `--experimental-test-tag-filter` to filter which tests run. Tags inherit from suites to nested tests by union. See Test tags."
                    },
                    {
                      "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."
                    }
                  ],
                  "optional": true
                },
                {
                  "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.",
                  "optional": true
                }
              ],
              "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."
              }
            }
          ],
          "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\"><code>&#x3C;TestsStream></code></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])`",
          "name": "skip",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "todo",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "only",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "describe",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "skip",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "todo",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "only",
          "type": "method",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "it",
          "type": "method",
          "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": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "skip",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "todo",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "only",
          "type": "method",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "name": "name",
                  "optional": true
                },
                {
                  "name": "options",
                  "optional": true
                },
                {
                  "name": "fn",
                  "optional": true
                }
              ]
            }
          ],
          "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])`",
          "name": "before",
          "type": "method",
          "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.",
                  "optional": true
                },
                {
                  "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."
                    }
                  ],
                  "optional": true
                }
              ]
            }
          ],
          "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    // Some relevant assertions here\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`after([fn][, options])`",
          "name": "after",
          "type": "method",
          "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.",
                  "optional": true
                },
                {
                  "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."
                    }
                  ],
                  "optional": true
                }
              ]
            }
          ],
          "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    // 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])`",
          "name": "beforeEach",
          "type": "method",
          "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.",
                  "optional": true
                },
                {
                  "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."
                    }
                  ],
                  "optional": true
                }
              ]
            }
          ],
          "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    // Some relevant assertion here\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`afterEach([fn][, options])`",
          "name": "afterEach",
          "type": "method",
          "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.",
                  "optional": true
                },
                {
                  "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."
                    }
                  ],
                  "optional": true
                }
              ]
            }
          ],
          "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    // Some relevant assertion here\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`getTestContext()`",
          "name": "getTestContext",
          "type": "method",
          "meta": {
            "added": [
              "v26.1.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {TestContext|SuiteContext|undefined}",
                "name": "return",
                "type": "TestContext|SuiteContext|undefined"
              }
            }
          ],
          "desc": "<p>Returns the <a href=\"#class-testcontext\"><code>TestContext</code></a> or <a href=\"#class-suitecontext\"><code>SuiteContext</code></a> object associated with the\ncurrently executing test or suite, or <code>undefined</code> if called outside of a test or\nsuite. This function can be used to access context information from within the\ntest or suite function or any async operations within them.</p>\n<pre><code class=\"language-mjs\">import { getTestContext } from 'node:test';\n\ntest('example test', async () => {\n  const ctx = getTestContext();\n  console.log(`Running test: ${ctx.name}`);\n});\n\ndescribe('example suite', () => {\n  const ctx = getTestContext();\n  console.log(`Running suite: ${ctx.name}`);\n});\n</code></pre>\n<p>When called from a test, returns a <a href=\"#class-testcontext\"><code>TestContext</code></a>.\nWhen called from a suite, returns a <a href=\"#class-suitecontext\"><code>SuiteContext</code></a>.</p>\n<p>If called from outside a test or suite (e.g., at the top level of a module or in\na setTimeout callback after execution has completed), this function returns\n<code>undefined</code>.</p>\n<p>When called from within a hook (before, beforeEach, after, afterEach), this\nfunction returns the context of the test or suite that the hook is associated\nwith.</p>"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `MockFunctionContext`",
          "name": "MockFunctionContext",
          "type": "class",
          "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": "Type: {Array}",
              "name": "calls",
              "type": "Array",
              "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/docs/Web/JavaScript/Reference/Global_Objects/Array\"><code>&#x3C;Array></code></a> An array of the arguments passed to the mock function.</li>\n<li><code>error</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#Data_types\"><code>&#x3C;any></code></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/docs/Web/JavaScript/Data_structures#Data_types\"><code>&#x3C;any></code></a> The value returned by the mocked function.</li>\n<li><code>stack</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error\"><code>&#x3C;Error></code></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/docs/Web/JavaScript/Reference/Global_Objects/Function\"><code>&#x3C;Function></code></a> | <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#undefined_type\"><code>&#x3C;undefined></code></a> If the mocked function is a constructor, this\nfield contains the class being constructed. Otherwise this will be <code>undefined</code>.</li>\n<li><code>this</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#Data_types\"><code>&#x3C;any></code></a> The mocked function's <code>this</code> value.</li>\n</ul>"
            }
          ],
          "methods": [
            {
              "textRaw": "`ctx.callCount()`",
              "name": "callCount",
              "type": "method",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "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."
                  }
                }
              ],
              "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)`",
              "name": "mockImplementation",
              "type": "method",
              "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])`",
              "name": "mockImplementationOnce",
              "type": "method",
              "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.",
                      "optional": true
                    }
                  ]
                }
              ],
              "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()`",
              "name": "resetCalls",
              "type": "method",
              "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()`",
              "name": "restore",
              "type": "method",
              "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`",
          "name": "MockModuleContext",
          "type": "class",
          "meta": {
            "added": [
              "v22.3.0",
              "v20.18.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": "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()`",
              "name": "restore",
              "type": "method",
              "meta": {
                "added": [
                  "v22.3.0",
                  "v20.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the implementation of the mock module.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `MockPropertyContext`",
          "name": "MockPropertyContext",
          "type": "class",
          "meta": {
            "added": [
              "v24.3.0",
              "v22.20.0"
            ],
            "changes": []
          },
          "desc": "<p>The <code>MockPropertyContext</code> class is used to inspect or manipulate the behavior\nof property mocks created via the <a href=\"#class-mocktracker\"><code>MockTracker</code></a> APIs.</p>",
          "properties": [
            {
              "textRaw": "Type: {Array}",
              "name": "accesses",
              "type": "Array",
              "desc": "<p>A getter that returns a copy of the internal array used to track accesses (get/set) to\nthe mocked property. Each entry in the array is an object with the following properties:</p>\n<ul>\n<li><code>type</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> Either <code>'get'</code> or <code>'set'</code>, indicating the type of access.</li>\n<li><code>value</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#Data_types\"><code>&#x3C;any></code></a> The value that was read (for <code>'get'</code>) or written (for <code>'set'</code>).</li>\n<li><code>stack</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error\"><code>&#x3C;Error></code></a> An <code>Error</code> object whose stack can be used to determine the\ncallsite of the mocked function invocation.</li>\n</ul>"
            }
          ],
          "methods": [
            {
              "textRaw": "`ctx.accessCount()`",
              "name": "accessCount",
              "type": "method",
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {integer} The number of times that the property was accessed (read or written).",
                    "name": "return",
                    "type": "integer",
                    "desc": "The number of times that the property was accessed (read or written)."
                  }
                }
              ],
              "desc": "<p>This function returns the number of times that the property was accessed.\nThis function is more efficient than checking <code>ctx.accesses.length</code> because\n<code>ctx.accesses</code> is a getter that creates a copy of the internal access tracking array.</p>"
            },
            {
              "textRaw": "`ctx.mockImplementation(value)`",
              "name": "mockImplementation",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`value` {any} The new value to be set as the mocked property value.",
                      "name": "value",
                      "type": "any",
                      "desc": "The new value to be set as the mocked property value."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to change the value returned by the mocked property getter.</p>"
            },
            {
              "textRaw": "`ctx.mockImplementationOnce(value[, onAccess])`",
              "name": "mockImplementationOnce",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`value` {any} The value to be used as the mock's implementation for the invocation number specified by `onAccess`.",
                      "name": "value",
                      "type": "any",
                      "desc": "The value to be used as the mock's implementation for the invocation number specified by `onAccess`."
                    },
                    {
                      "textRaw": "`onAccess` {integer} The invocation number that will use `value`. If the specified invocation has already occurred then an exception is thrown. **Default:** The number of the next invocation.",
                      "name": "onAccess",
                      "type": "integer",
                      "default": "The number of the next invocation",
                      "desc": "The invocation number that will use `value`. If the specified invocation has already occurred then an exception is thrown.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to change the behavior of an existing mock for a single\ninvocation. Once invocation <code>onAccess</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.property()</code>, calls the\nmock property, changes the mock implementation to a different value 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  const obj = { foo: 1 };\n\n  const prop = t.mock.property(obj, 'foo', 5);\n\n  assert.strictEqual(obj.foo, 5);\n  prop.mock.mockImplementationOnce(25);\n  assert.strictEqual(obj.foo, 25);\n  assert.strictEqual(obj.foo, 5);\n});\n</code></pre>",
              "modules": [
                {
                  "textRaw": "Caveat",
                  "name": "caveat",
                  "type": "module",
                  "desc": "<p>For consistency with the rest of the mocking API, this function treats both property gets and sets\nas accesses. If a property set occurs at the same access index, the \"once\" value will be consumed\nby the set operation, and the mocked property value will be changed to the \"once\" value. This may\nlead to unexpected behavior if you intend the \"once\" value to only be used for a get operation.</p>",
                  "displayName": "Caveat"
                }
              ]
            },
            {
              "textRaw": "`ctx.resetAccesses()`",
              "name": "resetAccesses",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the access history of the mocked property.</p>"
            },
            {
              "textRaw": "`ctx.restore()`",
              "name": "restore",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the implementation of the mock property to its original behavior. The\nmock can still be used after calling this function.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `MockTracker`",
          "name": "MockTracker",
          "type": "class",
          "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])`",
              "name": "fn",
              "type": "method",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "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.",
                      "optional": true
                    },
                    {
                      "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`.",
                      "optional": true
                    },
                    {
                      "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."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "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."
                  }
                }
              ],
              "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])`",
              "name": "getter",
              "type": "method",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "object"
                    },
                    {
                      "name": "methodName"
                    },
                    {
                      "name": "implementation",
                      "optional": true
                    },
                    {
                      "name": "options",
                      "optional": true
                    }
                  ]
                }
              ],
              "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])`",
              "name": "method",
              "type": "method",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "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]`.",
                      "optional": true
                    },
                    {
                      "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."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "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."
                  }
                }
              ],
              "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])`",
              "name": "module",
              "type": "method",
              "meta": {
                "added": [
                  "v22.3.0",
                  "v20.18.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v24.0.0",
                      "v22.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/58007",
                    "description": "Support JSON modules."
                  }
                ]
              },
              "stability": 1,
              "stabilityText": "Early development",
              "signatures": [
                {
                  "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": "`exports` {Object} Optional mocked exports. The `default` property, if provided, is used as the mocked module's default export. All other own enumerable properties are used as named exports. **This option cannot be used with `defaultExport` or `namedExports`.**If the mock is a CommonJS or builtin module, `exports.default` is used as the value of `module.exports`.If `exports.default` is not provided for a CommonJS or builtin mock, `module.exports` defaults to an empty object.If named exports are provided with a non-object default export, the mock throws an exception when used as a CommonJS or builtin module.",
                          "name": "exports",
                          "type": "Object",
                          "desc": "Optional mocked exports. The `default` property, if provided, is used as the mocked module's default export. All other own enumerable properties are used as named exports. **This option cannot be used with `defaultExport` or `namedExports`.**If the mock is a CommonJS or builtin module, `exports.default` is used as the value of `module.exports`.If `exports.default` is not provided for a CommonJS or builtin mock, `module.exports` defaults to an empty object.If named exports are provided with a non-object default export, the mock throws an exception when used as a CommonJS or builtin module."
                        },
                        {
                          "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`. **This option cannot be used with `options.exports`.** This option is deprecated and will be removed in a later version. Prefer `options.exports.default`.",
                          "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`. **This option cannot be used with `options.exports`.** This option is deprecated and will be removed in a later version. Prefer `options.exports.default`."
                        },
                        {
                          "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. **This option cannot be used with `options.exports`.** This option is deprecated and will be removed in a later version. Prefer `options.exports`.",
                          "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. **This option cannot be used with `options.exports`.** This option is deprecated and will be removed in a later version. Prefer `options.exports`."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "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."
                  }
                }
              ],
              "desc": "<p>This function is used to mock the exports of ECMAScript modules, CommonJS modules, JSON modules, and\nNode.js builtin modules. Any references to the original module prior to mocking are not impacted. In\norder to enable module mocking, Node.js must be started with the\n<a href=\"cli.html#--experimental-test-module-mocks\"><code>--experimental-test-module-mocks</code></a> command-line flag.</p>\n<p><strong>Note</strong>: <a href=\"module.html#customization-hooks\">module customization hooks</a> registered via the <strong>synchronous</strong> API effect resolution of\nthe <code>specifier</code> provided to <code>mock.module</code>. Customization hooks registered via the <strong>asynchronous</strong>\nAPI are currently ignored (because the test runner's loader is synchronous, and node does not\nsupport multi-chain / cross-chain loading).</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 'foo', which\n  // does not exist in the original 'node:readline' module.\n  const mock = t.mock.module('node:readline', {\n    exports: { foo: () => 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.foo(), 42);\n  assert.strictEqual(cjsImpl.foo(), 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.foo, undefined);\n  assert.strictEqual(cjsImpl.foo, undefined);\n});\n</code></pre>"
            },
            {
              "textRaw": "`mock.property(object, propertyName[, value])`",
              "name": "property",
              "type": "method",
              "meta": {
                "added": [
                  "v24.3.0",
                  "v22.20.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`object` {Object} The object whose value is being mocked.",
                      "name": "object",
                      "type": "Object",
                      "desc": "The object whose value is being mocked."
                    },
                    {
                      "textRaw": "`propertyName` {string|symbol} The identifier of the property on `object` to mock.",
                      "name": "propertyName",
                      "type": "string|symbol",
                      "desc": "The identifier of the property on `object` to mock."
                    },
                    {
                      "textRaw": "`value` {any} An optional value used as the mock value for `object[propertyName]`. **Default:** The original property value.",
                      "name": "value",
                      "type": "any",
                      "default": "The original property value",
                      "desc": "An optional value used as the mock value for `object[propertyName]`.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Proxy} A proxy to the mocked object. The mocked object contains a special `mock` property, which is an instance of `MockPropertyContext`, and can be used for inspecting and changing the behavior of the mocked property.",
                    "name": "return",
                    "type": "Proxy",
                    "desc": "A proxy to the mocked object. The mocked object contains a special `mock` property, which is an instance of `MockPropertyContext`, and can be used for inspecting and changing the behavior of the mocked property."
                  }
                }
              ],
              "desc": "<p>Creates a mock for a property value on an object. This allows you to track and control access to a specific property,\nincluding how many times it is read (getter) or written (setter), and to restore the original value after mocking.</p>\n<pre><code class=\"language-js\">test('mocks a property value', (t) => {\n  const obj = { foo: 42 };\n  const prop = t.mock.property(obj, 'foo', 100);\n\n  assert.strictEqual(obj.foo, 100);\n  assert.strictEqual(prop.mock.accessCount(), 1);\n  assert.strictEqual(prop.mock.accesses[0].type, 'get');\n  assert.strictEqual(prop.mock.accesses[0].value, 100);\n\n  obj.foo = 200;\n  assert.strictEqual(prop.mock.accessCount(), 2);\n  assert.strictEqual(prop.mock.accesses[1].type, 'set');\n  assert.strictEqual(prop.mock.accesses[1].value, 200);\n\n  prop.mock.restore();\n  assert.strictEqual(obj.foo, 42);\n});\n</code></pre>"
            },
            {
              "textRaw": "`mock.reset()`",
              "name": "reset",
              "type": "method",
              "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()`",
              "name": "restoreAll",
              "type": "method",
              "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])`",
              "name": "setter",
              "type": "method",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "object"
                    },
                    {
                      "name": "methodName"
                    },
                    {
                      "name": "implementation",
                      "optional": true
                    },
                    {
                      "name": "options",
                      "optional": true
                    }
                  ]
                }
              ],
              "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`",
          "name": "MockTimers",
          "type": "class",
          "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."
              }
            ]
          },
          "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])`",
              "name": "enable",
              "type": "method",
              "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": [
                    {
                      "textRaw": "`enableOptions` {Object} Optional configuration options for enabling timer mocking. The following properties are supported:",
                      "name": "enableOptions",
                      "type": "Object",
                      "desc": "Optional configuration options for enabling timer mocking. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`apis` {Array} An optional array containing the timers to mock. The currently supported timer values are `'setInterval'`, `'setTimeout'`, `'setImmediate'`, and `'Date'`. **Default:** `['setInterval', 'setTimeout', 'setImmediate', 'Date']`. If no array is provided, all time related APIs (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, `'clearTimeout'`, `'setImmediate'`, `'clearImmediate'`, and `'Date'`) will be mocked by default.",
                          "name": "apis",
                          "type": "Array",
                          "default": "`['setInterval', 'setTimeout', 'setImmediate', 'Date']`. If no array is provided, all time related APIs (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, `'clearTimeout'`, `'setImmediate'`, `'clearImmediate'`, and `'Date'`) will be mocked by default",
                          "desc": "An optional array containing the timers to mock. The currently supported timer values are `'setInterval'`, `'setTimeout'`, `'setImmediate'`, and `'Date'`."
                        },
                        {
                          "textRaw": "`now` {number|Date} An optional number or Date object representing the initial time (in milliseconds) to use as the value for `Date.now()`. **Default:** `0`.",
                          "name": "now",
                          "type": "number|Date",
                          "default": "`0`",
                          "desc": "An optional number or Date object representing the initial time (in milliseconds) to use as the value for `Date.now()`."
                        }
                      ],
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Enables timer mocking for the specified timers.</p>\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()`",
              "name": "reset",
              "type": "method",
              "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]()`",
              "name": "[Symbol.dispose]",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Calls <code>timers.reset()</code>.</p>"
            },
            {
              "textRaw": "`timers.tick([milliseconds])`",
              "name": "tick",
              "type": "method",
              "meta": {
                "added": [
                  "v20.4.0",
                  "v18.19.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`milliseconds` {number} The amount of time, in milliseconds, to advance the timers. **Default:** `1`.",
                      "name": "milliseconds",
                      "type": "number",
                      "default": "`1`",
                      "desc": "The amount of time, in milliseconds, to advance the timers.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Advances time for all mocked timers.</p>\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",
                  "type": "module",
                  "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>",
                  "displayName": "Using clear functions"
                },
                {
                  "textRaw": "Working with Node.js timers modules",
                  "name": "working_with_node.js_timers_modules",
                  "type": "module",
                  "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>",
                  "displayName": "Working with Node.js timers modules"
                }
              ]
            },
            {
              "textRaw": "`timers.runAll()`",
              "name": "runAll",
              "type": "method",
              "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)`",
              "name": "setTime",
              "type": "method",
              "meta": {
                "added": [
                  "v21.2.0",
                  "v20.11.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "milliseconds"
                    }
                  ]
                }
              ],
              "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",
                  "type": "module",
                  "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> advance 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>",
                  "displayName": "Dates and Timers working together"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "Class: `TestsStream`",
          "name": "TestsStream",
          "type": "class",
          "meta": {
            "added": [
              "v18.9.0",
              "v16.19.0"
            ],
            "changes": [
              {
                "version": "v26.3.0",
                "pr-url": "https://github.com/nodejs/node/pull/63435",
                "description": "Added `parentId` to test events that carry a `testId`."
              },
              {
                "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\"><code>&#x3C;Readable></code></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\"><code>&#x3C;TestsStream></code></a>\nobject, streaming a series of events representing the execution of the tests. <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'`",
              "name": "test:coverage",
              "type": "event",
              "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'`",
              "name": "test:complete",
              "type": "event",
              "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": "`parentId` {number|undefined} The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave.",
                      "name": "parentId",
                      "type": "number|undefined",
                      "desc": "The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave."
                    },
                    {
                      "textRaw": "`tags` {string}[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags.",
                      "name": "tags",
                      "type": "string",
                      "desc": "[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags."
                    },
                    {
                      "textRaw": "`testId` {number} A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters.",
                      "name": "testId",
                      "type": "number",
                      "desc": "A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters."
                    },
                    {
                      "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'`",
              "name": "test:dequeue",
              "type": "event",
              "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": "`parentId` {number|undefined} The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave.",
                      "name": "parentId",
                      "type": "number|undefined",
                      "desc": "The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave."
                    },
                    {
                      "textRaw": "`tags` {string}[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags.",
                      "name": "tags",
                      "type": "string",
                      "desc": "[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags."
                    },
                    {
                      "textRaw": "`testId` {number} A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters.",
                      "name": "testId",
                      "type": "number",
                      "desc": "A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters."
                    },
                    {
                      "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'`",
              "name": "test:diagnostic",
              "type": "event",
              "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."
                    },
                    {
                      "textRaw": "`level` {string} The severity level of the diagnostic message. Possible values are:",
                      "name": "level",
                      "type": "string",
                      "desc": "The severity level of the diagnostic message. Possible values are:",
                      "options": [
                        {
                          "textRaw": "`'info'`: Informational messages.",
                          "desc": "`'info'`: Informational messages."
                        },
                        {
                          "textRaw": "`'warn'`: Warnings.",
                          "desc": "`'warn'`: Warnings."
                        },
                        {
                          "textRaw": "`'error'`: Errors.",
                          "desc": "`'error'`: Errors."
                        }
                      ]
                    }
                  ]
                }
              ],
              "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'`",
              "name": "test:enqueue",
              "type": "event",
              "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": "`parentId` {number|undefined} The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave.",
                      "name": "parentId",
                      "type": "number|undefined",
                      "desc": "The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave."
                    },
                    {
                      "textRaw": "`tags` {string}[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags.",
                      "name": "tags",
                      "type": "string",
                      "desc": "[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags."
                    },
                    {
                      "textRaw": "`testId` {number} A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters.",
                      "name": "testId",
                      "type": "number",
                      "desc": "A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters."
                    },
                    {
                      "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'`",
              "name": "test:fail",
              "type": "event",
              "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": "`attempt` {number|undefined} The attempt number of the test run, present only when using the `--test-rerun-failures` flag.",
                          "name": "attempt",
                          "type": "number|undefined",
                          "desc": "The attempt number of the test run, present only when using the `--test-rerun-failures` flag."
                        }
                      ]
                    },
                    {
                      "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": "`parentId` {number|undefined} The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave.",
                      "name": "parentId",
                      "type": "number|undefined",
                      "desc": "The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave."
                    },
                    {
                      "textRaw": "`tags` {string}[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags.",
                      "name": "tags",
                      "type": "string",
                      "desc": "[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags."
                    },
                    {
                      "textRaw": "`testId` {number} A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters.",
                      "name": "testId",
                      "type": "number",
                      "desc": "A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters."
                    },
                    {
                      "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:interrupted'`",
              "name": "test:interrupted",
              "type": "event",
              "meta": {
                "added": [
                  "v25.7.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`tests` {Array} An array of objects containing information about the interrupted tests.",
                      "name": "tests",
                      "type": "Array",
                      "desc": "An array of objects containing information about the interrupted tests.",
                      "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 the test runner is interrupted by a <code>SIGINT</code> signal (e.g., when\npressing <kbd>Ctrl</kbd>+<kbd>C</kbd>). The event contains information about\nthe tests that were running at the time of interruption.</p>\n<p>When using process isolation (the default), the test name will be the file path\nsince the parent runner only knows about file-level tests. When using\n<code>--test-isolation=none</code>, the actual test name is shown.</p>"
            },
            {
              "textRaw": "Event: `'test:pass'`",
              "name": "test:pass",
              "type": "event",
              "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": "`attempt` {number|undefined} The attempt number of the test run, present only when using the `--test-rerun-failures` flag.",
                          "name": "attempt",
                          "type": "number|undefined",
                          "desc": "The attempt number of the test run, present only when using the `--test-rerun-failures` flag."
                        },
                        {
                          "textRaw": "`passed_on_attempt` {number|undefined} The attempt number the test passed on, present only when using the `--test-rerun-failures` flag.",
                          "name": "passed_on_attempt",
                          "type": "number|undefined",
                          "desc": "The attempt number the test passed on, present only when using the `--test-rerun-failures` flag."
                        }
                      ]
                    },
                    {
                      "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": "`parentId` {number|undefined} The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave.",
                      "name": "parentId",
                      "type": "number|undefined",
                      "desc": "The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave."
                    },
                    {
                      "textRaw": "`tags` {string}[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags.",
                      "name": "tags",
                      "type": "string",
                      "desc": "[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags."
                    },
                    {
                      "textRaw": "`testId` {number} A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters.",
                      "name": "testId",
                      "type": "number",
                      "desc": "A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters."
                    },
                    {
                      "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'`",
              "name": "test:plan",
              "type": "event",
              "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'`",
              "name": "test:start",
              "type": "event",
              "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": "`parentId` {number|undefined} The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave.",
                      "name": "parentId",
                      "type": "number|undefined",
                      "desc": "The `testId` of the enclosing test, or `undefined` for top-level tests. Lets custom reporters track lineage when concurrent siblings at the same nesting level interleave."
                    },
                    {
                      "textRaw": "`tags` {string}[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags.",
                      "name": "tags",
                      "type": "string",
                      "desc": "[] The flattened lowercased tags declared on the test and its ancestor suites, in declaration order. Empty for untagged tests. See Test tags."
                    },
                    {
                      "textRaw": "`testId` {number} A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters.",
                      "name": "testId",
                      "type": "number",
                      "desc": "A numeric identifier for this test instance, unique within the test file's process. Consistent across all events for the same test instance, enabling reliable correlation in custom reporters."
                    }
                  ]
                }
              ],
              "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'`",
              "name": "test:stderr",
              "type": "event",
              "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'`",
              "name": "test:stdout",
              "type": "event",
              "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'`",
              "name": "test:summary",
              "type": "event",
              "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'`",
              "name": "test:watch:drained",
              "type": "event",
              "params": [],
              "desc": "<p>Emitted when no more tests are queued for execution in watch mode.</p>"
            },
            {
              "textRaw": "Event: `'test:watch:restarted'`",
              "name": "test:watch:restarted",
              "type": "event",
              "params": [],
              "desc": "<p>Emitted when one or more tests are restarted due to a file change in watch mode.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `TestContext`",
          "name": "TestContext",
          "type": "class",
          "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])`",
              "name": "before",
              "type": "method",
              "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.",
                      "optional": true
                    },
                    {
                      "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."
                        }
                      ],
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook running before\nsubtest of the current test.</p>"
            },
            {
              "textRaw": "`context.beforeEach([fn][, options])`",
              "name": "beforeEach",
              "type": "method",
              "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.",
                      "optional": true
                    },
                    {
                      "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."
                        }
                      ],
                      "optional": true
                    }
                  ]
                }
              ],
              "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      // Some relevant assertion here\n    },\n  );\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.after([fn][, options])`",
              "name": "after",
              "type": "method",
              "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.",
                      "optional": true
                    },
                    {
                      "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."
                        }
                      ],
                      "optional": true
                    }
                  ]
                }
              ],
              "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  // Some relevant assertion here\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.afterEach([fn][, options])`",
              "name": "afterEach",
              "type": "method",
              "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.",
                      "optional": true
                    },
                    {
                      "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."
                        }
                      ],
                      "optional": true
                    }
                  ]
                }
              ],
              "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      // Some relevant assertion here\n    },\n  );\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.diagnostic(message)`",
              "name": "diagnostic",
              "type": "method",
              "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[,options])`",
              "name": "plan",
              "type": "method",
              "meta": {
                "added": [
                  "v22.2.0",
                  "v20.15.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v23.9.0",
                      "v22.15.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/56765",
                    "description": "Add the `options` parameter."
                  },
                  {
                    "version": [
                      "v23.4.0",
                      "v22.13.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."
                    },
                    {
                      "textRaw": "`options` {Object} Additional options for the plan.",
                      "name": "options",
                      "type": "Object",
                      "desc": "Additional options for the plan.",
                      "options": [
                        {
                          "textRaw": "`wait` {boolean|number} The wait time for the plan:If `true`, the plan waits indefinitely for all assertions and subtests to run.If `false`, the plan performs an immediate check after the test function completes, without waiting for any pending assertions or subtests. Any assertions or subtests that complete after this check will not be counted towards the plan.If a number, it specifies the maximum wait time in milliseconds before timing out while waiting for expected assertions and subtests to be matched. If the timeout is reached, the test will fail. **Default:** `false`.",
                          "name": "wait",
                          "type": "boolean|number",
                          "default": "`false`",
                          "desc": "The wait time for the plan:If `true`, the plan waits indefinitely for all assertions and subtests to run.If `false`, the plan performs an immediate check after the test function completes, without waiting for any pending assertions or subtests. Any assertions or subtests that complete after this check will not be counted towards the plan.If a number, it specifies the maximum wait time in milliseconds before timing out while waiting for expected assertions and subtests to be matched. If the timeout is reached, the test will fail."
                        }
                      ],
                      "optional": true
                    }
                  ]
                }
              ],
              "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>\n<p>When using the <code>wait</code> option, you can control how long the test will wait for the expected assertions.\nFor example, setting a maximum wait time ensures that the test will wait for asynchronous assertions\nto complete within the specified timeframe:</p>\n<pre><code class=\"language-js\">test('plan with wait: 2000 waits for async assertions', (t) => {\n  t.plan(1, { wait: 2000 }); // Waits for up to 2 seconds for the assertion to complete.\n\n  const asyncActivity = () => {\n    setTimeout(() => {\n      t.assert.ok(true, 'Async assertion completed within the wait time');\n    }, 1000); // Completes after 1 second, within the 2-second wait time.\n  };\n\n  asyncActivity(); // The test will pass because the assertion is completed in time.\n});\n</code></pre>\n<p>Note: If a <code>wait</code> timeout is specified, it begins counting down only after the test function finishes executing.</p>"
            },
            {
              "textRaw": "`context.runOnly(shouldRunOnlyTests)`",
              "name": "runOnly",
              "type": "method",
              "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])`",
              "name": "skip",
              "type": "method",
              "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.",
                      "optional": true
                    }
                  ]
                }
              ],
              "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])`",
              "name": "todo",
              "type": "method",
              "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.",
                      "optional": true
                    }
                  ]
                }
              ],
              "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])`",
              "name": "test",
              "type": "method",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": [
                  {
                    "version": "v26.2.0",
                    "pr-url": "https://github.com/nodejs/node/pull/63221",
                    "description": "Added the `tags` option."
                  },
                  {
                    "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": [
                {
                  "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.",
                      "optional": true
                    },
                    {
                      "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 asynchronously (they are still managed by the single-threaded event loop). 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 asynchronously (they are still managed by the single-threaded event loop). 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": "`tags` {string}[] An array of string labels associated with the subtest. Used together with `--experimental-test-tag-filter` to filter which tests run. Tags inherit from the parent test or suite by union. See Test tags. **Default:** `[]`.",
                          "name": "tags",
                          "type": "string",
                          "default": "`[]`",
                          "desc": "[] An array of string labels associated with the subtest. Used together with `--experimental-test-tag-filter` to filter which tests run. Tags inherit from the parent test or suite by union. See Test tags."
                        },
                        {
                          "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."
                        }
                      ],
                      "optional": true
                    },
                    {
                      "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.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise} Fulfilled with `undefined` once the test completes.",
                    "name": "return",
                    "type": "Promise",
                    "desc": "Fulfilled with `undefined` once the test completes."
                  }
                }
              ],
              "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])`",
              "name": "waitFor",
              "type": "method",
              "meta": {
                "added": [
                  "v23.7.0",
                  "v22.14.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "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."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise} Fulfilled with the value returned by `condition`.",
                    "name": "return",
                    "type": "Promise",
                    "desc": "Fulfilled with the value returned by `condition`."
                  }
                }
              ],
              "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",
              "type": "property",
              "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])`",
                  "name": "fileSnapshot",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v23.7.0",
                      "v22.14.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."
                            }
                          ],
                          "optional": true
                        }
                      ]
                    }
                  ],
                  "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])`",
                  "name": "snapshot",
                  "type": "method",
                  "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."
                            }
                          ],
                          "optional": true
                        }
                      ]
                    }
                  ],
                  "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",
              "type": "property",
              "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",
              "type": "property",
              "meta": {
                "added": [
                  "v22.3.0",
                  "v20.16.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the test and each of its ancestors, separated by <code>></code>.</p>"
            },
            {
              "textRaw": "`context.name`",
              "name": "name",
              "type": "property",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the test.</p>"
            },
            {
              "textRaw": "Type: {boolean} `false` before the test is executed, e.g. in a `beforeEach` hook.",
              "name": "passed",
              "type": "boolean",
              "meta": {
                "added": [
                  "v21.7.0",
                  "v20.12.0"
                ],
                "changes": []
              },
              "desc": "<p>Indicated whether the test succeeded.</p>",
              "shortDesc": "`false` before the test is executed, e.g. in a `beforeEach` hook."
            },
            {
              "textRaw": "Type: {Error|null}",
              "name": "error",
              "type": "Error|null",
              "meta": {
                "added": [
                  "v21.7.0",
                  "v20.12.0"
                ],
                "changes": []
              },
              "desc": "<p>The failure reason for the test/case; wrapped and available via <code>context.error.cause</code>.</p>"
            },
            {
              "textRaw": "Type: {number}",
              "name": "attempt",
              "type": "number",
              "meta": {
                "added": [
                  "v25.0.0"
                ],
                "changes": []
              },
              "desc": "<p>The attempt number of the test. This value is zero-based, so the first attempt is <code>0</code>,\nthe second attempt is <code>1</code>, and so on. This property is useful in conjunction with the\n<code>--test-rerun-failures</code> option to determine which attempt the test is currently running.</p>"
            },
            {
              "textRaw": "Type: {string}[]",
              "name": "tags",
              "type": "string",
              "meta": {
                "added": [
                  "v26.2.0"
                ],
                "changes": []
              },
              "stability": 1,
              "stabilityText": "Early development",
              "desc": "<p>A frozen array of the test's flattened lowercased tags, in declaration\norder, including any tags inherited from ancestor suites. Empty when the\ntest has no tags. See <a href=\"#test-tags\">Test tags</a>.</p>",
              "shortDesc": "[]"
            },
            {
              "textRaw": "Type: {number|undefined}",
              "name": "workerId",
              "type": "number|undefined",
              "meta": {
                "added": [
                  "v25.8.0"
                ],
                "changes": []
              },
              "desc": "<p>The unique identifier of the worker running the current test file. This value is\nderived from the <code>NODE_TEST_WORKER_ID</code> environment variable. When running tests\nwith <code>--test-isolation=process</code> (the default), each test file runs in a separate\nchild process and is assigned a worker ID from 1 to N, where N is the number of\nconcurrent workers. When running with <code>--test-isolation=none</code>, all tests run in\nthe same process and the worker ID is always 1. This value is <code>undefined</code> when\nnot running in a test context.</p>\n<p>This property is useful for splitting resources (like database connections or\nserver ports) across concurrent test files:</p>\n<pre><code class=\"language-mjs\">import { test } from 'node:test';\nimport { process } from 'node:process';\n\ntest('database operations', async (t) => {\n  // Worker ID is available via context\n  console.log(`Running in worker ${t.workerId}`);\n\n  // Or via environment variable (available at import time)\n  const workerId = process.env.NODE_TEST_WORKER_ID;\n  // Use workerId to allocate separate resources per worker\n});\n</code></pre>"
            },
            {
              "textRaw": "Type: {AbortSignal}",
              "name": "signal",
              "type": "AbortSignal",
              "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`",
          "name": "SuiteContext",
          "type": "class",
          "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",
              "type": "property",
              "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.fullName`",
              "name": "fullName",
              "type": "property",
              "meta": {
                "added": [
                  "v22.3.0",
                  "v20.16.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the suite and each of its ancestors, separated by <code>></code>.</p>"
            },
            {
              "textRaw": "`context.name`",
              "name": "name",
              "type": "property",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the suite.</p>"
            },
            {
              "textRaw": "Type: {AbortSignal}",
              "name": "signal",
              "type": "AbortSignal",
              "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>"
            },
            {
              "textRaw": "Type: {boolean}",
              "name": "passed",
              "type": "boolean",
              "meta": {
                "added": [
                  "v26.1.0"
                ],
                "changes": []
              },
              "desc": "<p>Indicates whether the suite and all of its subtests have passed.</p>"
            },
            {
              "textRaw": "Type: {number}",
              "name": "attempt",
              "type": "number",
              "meta": {
                "added": [
                  "v26.1.0"
                ],
                "changes": []
              },
              "desc": "<p>The attempt number of the suite. This value is zero-based, so the first attempt is <code>0</code>,\nthe second attempt is <code>1</code>, and so on. This property is useful in conjunction with the\n<code>--test-rerun-failures</code> option to determine the attempt number of the current run.</p>"
            }
          ],
          "methods": [
            {
              "textRaw": "`context.diagnostic(message)`",
              "name": "diagnostic",
              "type": "method",
              "meta": {
                "added": [
                  "v26.1.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {string} A diagnostic message to output.",
                      "name": "message",
                      "type": "string",
                      "desc": "A diagnostic message to output."
                    }
                  ]
                }
              ],
              "desc": "<p>Output a diagnostic message. This is typically used for logging information\nabout the current suite or its tests.</p>\n<pre><code class=\"language-js\">test.describe('my suite', (suite) => {\n  suite.diagnostic('Suite diagnostic message');\n});\n</code></pre>"
            }
          ]
        }
      ],
      "displayName": "Test runner"
    }
  ]
}