{
  "type": "module",
  "source": "doc/api/test.md",
  "modules": [
    {
      "textRaw": "Test runner",
      "name": "test_runner",
      "introduced_in": "v18.0.0",
      "meta": {
        "added": [
          "v18.0.0",
          "v16.17.0"
        ],
        "changes": [
          {
            "version": "REPLACEME",
            "pr-url": "https://github.com/nodejs/node/pull/46983",
            "description": "The test runner is now stable."
          }
        ]
      },
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p><strong>Source Code:</strong> <a href=\"https://github.com/nodejs/node/blob/v20.0.0-test09a4bb152f/lib/test.js\">lib/test.js</a></p>\n<p>The <code>node:test</code> module facilitates the creation of JavaScript tests.\nTo access it:</p>\n<pre><code class=\"language-mjs\">import test from 'node:test';\n</code></pre>\n<pre><code class=\"language-cjs\">const test = require('node:test');\n</code></pre>\n<p>This module is only available under the <code>node:</code> scheme. The following will not\nwork:</p>\n<pre><code class=\"language-mjs\">import test from 'test';\n</code></pre>\n<pre><code class=\"language-cjs\">const test = require('test');\n</code></pre>\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> resolves.</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 not rejected.\n  assert.strictEqual(1, 1);\n});\n\ntest('asynchronous failing test', async (t) => {\n  // This test fails because the Promise returned by the async\n  // function is rejected.\n  assert.strictEqual(1, 2);\n});\n\ntest('failing test using Promises', (t) => {\n  // Promises can be used directly as well.\n  return new Promise((resolve, reject) => {\n    setImmediate(() => {\n      reject(new Error('this will cause the test to fail'));\n    });\n  });\n});\n\ntest('callback passing test', (t, done) => {\n  // done() is the callback function. When the setImmediate() runs, it invokes\n  // done() with no arguments.\n  setImmediate(done);\n});\n\ntest('callback failing test', (t, done) => {\n  // When the setImmediate() runs, done() is invoked with an Error object and\n  // the test fails.\n  setImmediate(() => {\n    done(new Error('callback failure'));\n  });\n});\n</code></pre>\n<p>If any tests fail, the process exit code is set to <code>1</code>.</p>",
      "modules": [
        {
          "textRaw": "Subtests",
          "name": "subtests",
          "desc": "<p>The test context's <code>test()</code> method allows subtests to be created. This method\nbehaves identically to the top level <code>test()</code> function. The following example\ndemonstrates the creation of a top 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<p>In this example, <code>await</code> is used to ensure that both subtests have completed.\nThis is necessary because parent tests do not wait for their subtests to\ncomplete. Any subtests that are still outstanding when their parent finishes\nare cancelled and treated as failures. Any subtest failures cause the parent\ntest to fail.</p>",
          "type": "module",
          "displayName": "Subtests"
        },
        {
          "textRaw": "Skipping tests",
          "name": "skipping_tests",
          "desc": "<p>Individual tests can be skipped by passing the <code>skip</code> option to the test, or by\ncalling the test context's <code>skip()</code> method as shown in the\nfollowing example.</p>\n<pre><code class=\"language-js\">// The skip option is used, but no message is provided.\ntest('skip option', { skip: true }, (t) => {\n  // This code is never executed.\n});\n\n// The skip option is used, and a message is provided.\ntest('skip option with message', { skip: 'this is skipped' }, (t) => {\n  // This code is never executed.\n});\n\ntest('skip() method', (t) => {\n  // Make sure to return here as well if the test contains additional logic.\n  t.skip();\n});\n\ntest('skip() method with message', (t) => {\n  // Make sure to return here as well if the test contains additional logic.\n  t.skip('this is skipped');\n});\n</code></pre>",
          "type": "module",
          "displayName": "Skipping tests"
        },
        {
          "textRaw": "`describe`/`it` syntax",
          "name": "`describe`/`it`_syntax",
          "desc": "<p>Running tests can also be done using <code>describe</code> to declare a suite\nand <code>it</code> to declare a test.\nA suite is used to organize and group related tests together.\n<code>it</code> is a shorthand for <a href=\"#testname-options-fn\"><code>test()</code></a>.</p>\n<pre><code class=\"language-js\">describe('A thing', () => {\n  it('should work', () => {\n    assert.strictEqual(1, 1);\n  });\n\n  it('should be ok', () => {\n    assert.strictEqual(2, 2);\n  });\n\n  describe('a nested thing', () => {\n    it('should work', () => {\n      assert.strictEqual(3, 3);\n    });\n  });\n});\n</code></pre>\n<p><code>describe</code> and <code>it</code> are imported from the <code>node:test</code> module.</p>\n<pre><code class=\"language-mjs\">import { describe, it } from 'node:test';\n</code></pre>\n<pre><code class=\"language-cjs\">const { describe, it } = require('node:test');\n</code></pre>",
          "type": "module",
          "displayName": "`describe`/`it` syntax"
        },
        {
          "textRaw": "`only` tests",
          "name": "`only`_tests",
          "desc": "<p>If Node.js is started with the <a href=\"cli.html#--test-only\"><code>--test-only</code></a> command-line option, it is\npossible to skip all top level tests except for a selected subset by passing\nthe <code>only</code> option to the tests that should be run. When a test with the <code>only</code>\noption set is run, all subtests are also run. The test context's <code>runOnly()</code>\nmethod can be used to implement the same behavior at the subtest level.</p>\n<pre><code class=\"language-js\">// Assume Node.js is run with the --test-only command-line option.\n// The 'only' option is set, so this test is 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</code></pre>",
          "type": "module",
          "displayName": "`only` tests"
        },
        {
          "textRaw": "Filtering tests by name",
          "name": "filtering_tests_by_name",
          "desc": "<p>The <a href=\"cli.html#--test-name-pattern\"><code>--test-name-pattern</code></a> command-line option can be used to only run tests\nwhose name matches the provided pattern. Test name patterns are interpreted as\nJavaScript regular expressions. The <code>--test-name-pattern</code> option can be\nspecified multiple times in order to run nested tests. For each test that is\nexecuted, any corresponding test hooks, such as <code>beforeEach()</code>, are also\nrun.</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> would match <code>Test 4</code> and\n<code>Test 5</code> because the pattern is case-insensitive.</p>\n<p>Test name patterns do not change the set of files that the test runner executes.</p>",
          "type": "module",
          "displayName": "Filtering tests by name"
        },
        {
          "textRaw": "Extraneous asynchronous activity",
          "name": "extraneous_asynchronous_activity",
          "desc": "<p>Once a test function finishes executing, the results are reported as quickly\nas possible while maintaining the order of the tests. However, it is possible\nfor the test function to generate asynchronous activity that outlives the test\nitself. The test runner handles this type of activity, but does not delay the\nreporting of test results in order to accommodate it.</p>\n<p>In the following example, a test completes with two <code>setImmediate()</code>\noperations still outstanding. The first <code>setImmediate()</code> attempts to create a\nnew subtest. Because the parent test has already finished and output its\nresults, the new subtest is immediately marked as failed, and reported later\nto the <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<p>The second <code>setImmediate()</code> creates an <code>uncaughtException</code> event.\n<code>uncaughtException</code> and <code>unhandledRejection</code> events originating from a completed\ntest are marked as failed by the <code>test</code> module and reported as diagnostic\nwarnings at the top level by the <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<pre><code class=\"language-js\">test('a test that creates asynchronous activity', (t) => {\n  setImmediate(() => {\n    t.test('subtest that is created too late', (t) => {\n      throw new Error('error1');\n    });\n  });\n\n  setImmediate(() => {\n    throw new Error('error2');\n  });\n\n  // The test finishes after this line.\n});\n</code></pre>",
          "type": "module",
          "displayName": "Extraneous asynchronous activity"
        },
        {
          "textRaw": "Watch mode",
          "name": "watch_mode",
          "meta": {
            "added": [
              "v19.2.0",
              "v18.13.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": "Experimental",
          "desc": "<p>The Node.js test runner supports running in watch mode by passing the <code>--watch</code> flag:</p>\n<pre><code class=\"language-bash\">node --test --watch\n</code></pre>\n<p>In watch mode, the test runner will watch for changes to test files and\ntheir dependencies. When a change is detected, the test runner will\nrerun the tests affected by the change.\nThe test runner will continue to run until the process is terminated.</p>",
          "type": "module",
          "displayName": "Watch mode"
        },
        {
          "textRaw": "Running tests from the command line",
          "name": "running_tests_from_the_command_line",
          "desc": "<p>The Node.js test runner can be invoked from the command line by passing the\n<a href=\"cli.html#--test\"><code>--test</code></a> flag:</p>\n<pre><code class=\"language-bash\">node --test\n</code></pre>\n<p>By default, Node.js will recursively search the current directory for\nJavaScript source files matching a specific naming convention. Matching files\nare executed as test files. More information on the expected test file naming\nconvention and behavior can be found in the <a href=\"#test-runner-execution-model\">test runner execution model</a>\nsection.</p>\n<p>Alternatively, one or more paths can be provided as the final argument(s) to\nthe Node.js command, as shown below.</p>\n<pre><code class=\"language-bash\">node --test test1.js test2.mjs custom_test_dir/\n</code></pre>\n<p>In this example, the test runner will execute the files <code>test1.js</code> and\n<code>test2.mjs</code>. The test runner will also recursively search the\n<code>custom_test_dir/</code> directory for test files to execute.</p>",
          "modules": [
            {
              "textRaw": "Test runner execution model",
              "name": "test_runner_execution_model",
              "desc": "<p>When searching for test files to execute, the test runner behaves as follows:</p>\n<ul>\n<li>Any files explicitly provided by the user are executed.</li>\n<li>If the user did not explicitly specify any paths, the current working\ndirectory is recursively searched for files as specified in the following\nsteps.</li>\n<li><code>node_modules</code> directories are skipped unless explicitly provided by the\nuser.</li>\n<li>If a directory named <code>test</code> is encountered, the test runner will search it\nrecursively for all all <code>.js</code>, <code>.cjs</code>, and <code>.mjs</code> files. All of these files\nare treated as test files, and do not need to match the specific naming\nconvention detailed below. This is to accommodate projects that place all of\ntheir tests in a single <code>test</code> directory.</li>\n<li>In all other directories, <code>.js</code>, <code>.cjs</code>, and <code>.mjs</code> files matching the\nfollowing patterns are treated as test files:\n<ul>\n<li><code>^test$</code> - Files whose basename is the string <code>'test'</code>. Examples:\n<code>test.js</code>, <code>test.cjs</code>, <code>test.mjs</code>.</li>\n<li><code>^test-.+</code> - Files whose basename starts with the string <code>'test-'</code>\nfollowed by one or more characters. Examples: <code>test-example.js</code>,\n<code>test-another-example.mjs</code>.</li>\n<li><code>.+[\\.\\-\\_]test$</code> - Files whose basename ends with <code>.test</code>, <code>-test</code>, or\n<code>_test</code>, preceded by one or more characters. Examples: <code>example.test.js</code>,\n<code>example-test.cjs</code>, <code>example_test.mjs</code>.</li>\n<li>Other file types understood by Node.js such as <code>.node</code> and <code>.json</code> are not\nautomatically executed by the test runner, but are supported if explicitly\nprovided on the command line.</li>\n</ul>\n</li>\n</ul>\n<p>Each matching test file is executed in a separate child process. If the child\nprocess 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\nexecutable by Node.js, but are not required to use the <code>node:test</code> module\ninternally.</p>",
              "type": "module",
              "displayName": "Test runner execution model"
            }
          ],
          "type": "module",
          "displayName": "Running tests from the command line"
        },
        {
          "textRaw": "Collecting code coverage",
          "name": "collecting_code_coverage",
          "stability": 1,
          "stabilityText": "Experimental",
          "desc": "<p>When Node.js is started with the <a href=\"cli.html#--experimental-test-coverage\"><code>--experimental-test-coverage</code></a>\ncommand-line flag, code coverage is collected and statistics are reported once\nall tests have completed. If the <a href=\"cli.html#node_v8_coveragedir\"><code>NODE_V8_COVERAGE</code></a> environment variable is\nused to specify a code coverage directory, the generated V8 coverage files are\nwritten to that directory. Node.js core modules and files within\n<code>node_modules/</code> directories are not included in the coverage report. If\ncoverage 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>\n<p>The test runner's code coverage functionality has the following limitations,\nwhich will be addressed in a future Node.js release:</p>\n<ul>\n<li>Although coverage data is collected for child processes, this information is\nnot included in the coverage report. Because the command line test runner uses\nchild processes to execute test files, it cannot be used with\n<code>--experimental-test-coverage</code>.</li>\n<li>Source maps are not supported.</li>\n<li>Excluding specific files or directories from the coverage report is not\nsupported.</li>\n</ul>",
          "type": "module",
          "displayName": "Collecting code coverage"
        },
        {
          "textRaw": "Mocking",
          "name": "mocking",
          "desc": "<p>The <code>node:test</code> module supports mocking during testing via a top-level <code>mock</code>\nobject. The following example creates a spy on a function that adds two numbers\ntogether. The spy is then used to assert that the function was called as\nexpected.</p>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport { mock, test } from 'node:test';\n\ntest('spies on a function', () => {\n  const sum = mock.fn((a, b) => {\n    return a + b;\n  });\n\n  assert.strictEqual(sum.mock.calls.length, 0);\n  assert.strictEqual(sum(3, 4), 7);\n  assert.strictEqual(sum.mock.calls.length, 1);\n\n  const call = sum.mock.calls[0];\n  assert.deepStrictEqual(call.arguments, [3, 4]);\n  assert.strictEqual(call.result, 7);\n  assert.strictEqual(call.error, undefined);\n\n  // Reset the globally tracked mocks.\n  mock.reset();\n});\n</code></pre>\n<pre><code class=\"language-cjs\">'use strict';\nconst assert = require('node:assert');\nconst { mock, test } = require('node:test');\n\ntest('spies on a function', () => {\n  const sum = mock.fn((a, b) => {\n    return a + b;\n  });\n\n  assert.strictEqual(sum.mock.calls.length, 0);\n  assert.strictEqual(sum(3, 4), 7);\n  assert.strictEqual(sum.mock.calls.length, 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.calls.length, 0);\n  assert.strictEqual(number.add(3), 8);\n  assert.strictEqual(number.add.mock.calls.length, 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>",
          "type": "module",
          "displayName": "Mocking"
        },
        {
          "textRaw": "Test reporters",
          "name": "test_reporters",
          "meta": {
            "added": [
              "v19.6.0",
              "v18.15.0"
            ],
            "changes": [
              {
                "version": "REPLACEME",
                "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>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>spec</code>\nThe <code>spec</code> reporter outputs the test results in a human-readable 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</ul>\n<p>When <code>stdout</code> is a <a href=\"tty.html\">TTY</a>, the <code>spec</code> reporter is used by default.\nOtherwise, the <code>tap</code> reporter is used by default.</p>\n<p>The exact output of these reporters is subject to change between versions of\nNode.js, and should not be relied on programmatically. If programmatic access\nto the test runner's output is required, use the events emitted by the\n<a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<p>The reporters are available via the <code>node:test/reporters</code> module:</p>\n<pre><code class=\"language-mjs\">import { tap, spec, dot } from 'node:test/reporters';\n</code></pre>\n<pre><code class=\"language-cjs\">const { tap, spec, dot } = require('node:test/reporters');\n</code></pre>",
          "modules": [
            {
              "textRaw": "Custom reporters",
              "name": "custom_reporters",
              "desc": "<p><a href=\"cli.html#--test-reporter\"><code>--test-reporter</code></a> can be used to specify a path to custom reporter.\nA custom reporter is a module that exports a value\naccepted by <a href=\"stream.html#streamcomposestreams\">stream.compose</a>.\nReporters should transform events emitted by a <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a></p>\n<p>Example of a custom reporter using <a href=\"stream.html#class-streamtransform\" class=\"type\">&lt;stream.Transform&gt;</a>:</p>\n<pre><code class=\"language-mjs\">import { Transform } from 'node:stream';\n\nconst customReporter = new Transform({\n  writableObjectMode: true,\n  transform(event, encoding, callback) {\n    switch (event.type) {\n      case 'test: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        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: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        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: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        break;\n      case 'test:diagnostic':\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: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        yield `${event.data.message}\\n`;\n        break;\n      case 'test:coverage': {\n        const { totalLineCount } = event.data.summary.totals;\n        yield `total line count: ${totalLineCount}\\n`;\n        break;\n      }\n    }\n  }\n};\n</code></pre>\n<p>The value provided to <code>--test-reporter</code> should be a string like one used in an\n<code>import()</code> in JavaScript code, or a value provided for <a href=\"cli.html#--importmodule\"><code>--import</code></a>.</p>",
              "type": "module",
              "displayName": "Custom reporters"
            },
            {
              "textRaw": "Multiple reporters",
              "name": "multiple_reporters",
              "desc": "<p>The <a href=\"cli.html#--test-reporter\"><code>--test-reporter</code></a> flag can be specified multiple times to report test\nresults in several formats. In this situation\nit is required to specify a destination for each reporter\nusing <a href=\"cli.html#--test-reporter-destination\"><code>--test-reporter-destination</code></a>.\nDestination can be <code>stdout</code>, <code>stderr</code>, or a file path.\nReporters and destinations are paired according\nto the order they were specified.</p>\n<p>In the following example, the <code>spec</code> reporter will output to <code>stdout</code>,\nand the <code>dot</code> reporter will output to <code>file.txt</code>:</p>\n<pre><code class=\"language-bash\">node --test-reporter=spec --test-reporter=dot --test-reporter-destination=stdout --test-reporter-destination=file.txt\n</code></pre>\n<p>When a single reporter is specified, the destination will default to <code>stdout</code>,\nunless a destination is explicitly provided.</p>",
              "type": "module",
              "displayName": "Multiple reporters"
            }
          ],
          "type": "module",
          "displayName": "Test reporters"
        }
      ],
      "methods": [
        {
          "textRaw": "`run([options])`",
          "type": "method",
          "name": "run",
          "meta": {
            "added": [
              "v18.9.0",
              "v16.19.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "return": {
                "textRaw": "Returns: {TestsStream}",
                "name": "return",
                "type": "TestsStream"
              },
              "params": [
                {
                  "textRaw": "`options` {Object} Configuration options for running tests. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for running tests. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`concurrency` {number|boolean} If a number is provided, then that many files would run in parallel. 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 files would run in parallel. 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": "`files`: {Array} An array containing the list of files to run. **Default** matching files from [test runner execution model][].",
                      "name": "files",
                      "type": "Array",
                      "desc": "An array containing the list of files to run. **Default** matching files from [test runner execution model][]."
                    },
                    {
                      "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": "`signal` {AbortSignal} Allows aborting an in-progress test execution.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress test execution."
                    },
                    {
                      "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": "`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`. **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`."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<pre><code class=\"language-mjs\">import { tap } from 'node:test/reporters';\nimport process from 'node:process';\n\nrun({ files: [path.resolve('./tests/test.js')] })\n  .compose(tap)\n  .pipe(process.stdout);\n</code></pre>\n<pre><code class=\"language-cjs\">const { tap } = require('node:test/reporters');\n\nrun({ files: [path.resolve('./tests/test.js')] })\n  .compose(tap)\n  .pipe(process.stdout);\n</code></pre>"
        },
        {
          "textRaw": "`test([name][, options][, fn])`",
          "type": "method",
          "name": "test",
          "meta": {
            "added": [
              "v18.0.0",
              "v16.17.0"
            ],
            "changes": [
              {
                "version": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/43554",
                "description": "Add a `signal` option."
              },
              {
                "version": [
                  "v18.7.0",
                  "v16.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/43505",
                "description": "Add a `timeout` option."
              }
            ]
          },
          "signatures": [
            {
              "return": {
                "textRaw": "Returns: {Promise} Resolved with `undefined` once the test completes, or immediately if the test runs within [`describe()`][].",
                "name": "return",
                "type": "Promise",
                "desc": "Resolved with `undefined` once the test completes, or immediately if the test runs within [`describe()`][]."
              },
              "params": [
                {
                  "textRaw": "`name` {string} The name of the test, which is displayed when reporting test results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.",
                  "name": "name",
                  "type": "string",
                  "default": "The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name",
                  "desc": "The name of the test, which is displayed when reporting test results."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the test. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the test. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`concurrency` {number|boolean} If a number is provided, then that many tests would run in parallel. If `true`, it would run `os.availableParallelism() - 1` tests in parallel. For subtests, it will be `Infinity` tests in parallel. If `false`, it would only run one test at a time. If unspecified, subtests inherit this value from their parent. **Default:** `false`.",
                      "name": "concurrency",
                      "type": "number|boolean",
                      "default": "`false`",
                      "desc": "If a number is provided, then that many tests would run in parallel. If `true`, it would run `os.availableParallelism() - 1` tests in parallel. For subtests, it will be `Infinity` tests in parallel. If `false`, it would only run one test at a time. If unspecified, subtests inherit this value from their parent."
                    },
                    {
                      "textRaw": "`only` {boolean} If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped. **Default:** `false`.",
                      "name": "only",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped."
                    },
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress test.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress test."
                    },
                    {
                      "textRaw": "`skip` {boolean|string} If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test. **Default:** `false`.",
                      "name": "skip",
                      "type": "boolean|string",
                      "default": "`false`",
                      "desc": "If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test."
                    },
                    {
                      "textRaw": "`todo` {boolean|string} If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`. **Default:** `false`.",
                      "name": "todo",
                      "type": "boolean|string",
                      "default": "`false`",
                      "desc": "If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                },
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument."
                }
              ]
            }
          ],
          "desc": "<p>The <code>test()</code> function is the value imported from the <code>test</code> module. Each\ninvocation of this function results in reporting the test to the <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>.</p>\n<p>The <code>TestContext</code> object passed to the <code>fn</code> argument can be used to perform\nactions related to the current test. Examples include skipping the test, adding\nadditional diagnostic information, or creating subtests.</p>\n<p><code>test()</code> returns a <code>Promise</code> that resolves once the test completes.\nif <code>test()</code> is called within a <code>describe()</code> block, it resolve 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": "`describe([name][, options][, fn])`",
          "type": "method",
          "name": "describe",
          "signatures": [
            {
              "return": {
                "textRaw": "Returns: `undefined`.",
                "name": "return",
                "desc": "`undefined`."
              },
              "params": [
                {
                  "textRaw": "`name` {string} The name of the suite, which is displayed when reporting test results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.",
                  "name": "name",
                  "type": "string",
                  "default": "The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name",
                  "desc": "The name of the suite, which is displayed when reporting test results."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the suite. supports the same options as `test([name][, options][, fn])`.",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the suite. supports the same options as `test([name][, options][, fn])`."
                },
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The function under suite declaring all subtests and subsuites. 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 function under suite declaring all subtests and subsuites. The first argument to this function is a [`SuiteContext`][] object."
                }
              ]
            }
          ],
          "desc": "<p>The <code>describe()</code> function imported from the <code>node:test</code> module. Each\ninvocation of this function results in the creation of a Subtest.\nAfter invocation of top level <code>describe</code> functions,\nall top level tests and suites will execute.</p>"
        },
        {
          "textRaw": "`describe.skip([name][, options][, fn])`",
          "type": "method",
          "name": "skip",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for skipping a suite, same as <a href=\"#describename-options-fn\"><code>describe([name], { skip: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`describe.todo([name][, options][, fn])`",
          "type": "method",
          "name": "todo",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a suite as <code>TODO</code>, same as\n<a href=\"#describename-options-fn\"><code>describe([name], { todo: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`describe.only([name][, options][, fn])`",
          "type": "method",
          "name": "only",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a suite as <code>only</code>, same as\n<a href=\"#describename-options-fn\"><code>describe([name], { only: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`it([name][, options][, fn])`",
          "type": "method",
          "name": "it",
          "meta": {
            "added": [
              "v18.6.0",
              "v16.17.0"
            ],
            "changes": [
              {
                "version": "v19.8.0",
                "pr-url": "https://github.com/nodejs/node/pull/46889",
                "description": "Calling `it()` is now equivalent to calling `test()`."
              }
            ]
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for <a href=\"#testname-options-fn\"><code>test()</code></a>.</p>\n<p>The <code>it()</code> function is imported from the <code>node:test</code> module.</p>"
        },
        {
          "textRaw": "`it.skip([name][, options][, fn])`",
          "type": "method",
          "name": "skip",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for skipping a test,\nsame as <a href=\"#testname-options-fn\"><code>it([name], { skip: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`it.todo([name][, options][, fn])`",
          "type": "method",
          "name": "todo",
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a test as <code>TODO</code>,\nsame as <a href=\"#testname-options-fn\"><code>it([name], { todo: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`it.only([name][, options][, fn])`",
          "type": "method",
          "name": "only",
          "meta": {
            "added": [
              "v19.8.0",
              "v18.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>Shorthand for marking a test as <code>only</code>,\nsame as <a href=\"#testname-options-fn\"><code>it([name], { only: true }[, fn])</code></a>.</p>"
        },
        {
          "textRaw": "`before([fn][, options])`",
          "type": "method",
          "name": "before",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function is used to create a hook running before running a suite.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  before(() => console.log('about to run some test'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`after([fn][, options])`",
          "type": "method",
          "name": "after",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function is used to create a hook running after  running a suite.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  after(() => console.log('finished running tests'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`beforeEach([fn][, options])`",
          "type": "method",
          "name": "beforeEach",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function is used to create a hook running\nbefore each subtest of the current suite.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  beforeEach(() => console.log('about to run a test'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>"
        },
        {
          "textRaw": "`afterEach([fn][, options])`",
          "type": "method",
          "name": "afterEach",
          "meta": {
            "added": [
              "v18.8.0",
              "v16.18.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`fn` {Function|AsyncFunction} The hook function. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                  "name": "fn",
                  "type": "Function|AsyncFunction",
                  "default": "A no-op function",
                  "desc": "The hook function. If the hook uses callbacks, the callback function is passed as the second argument."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the hook. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                      "name": "signal",
                      "type": "AbortSignal",
                      "desc": "Allows aborting an in-progress hook."
                    },
                    {
                      "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`Infinity`",
                      "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This function is used to create a hook running\nafter each subtest of the current test.</p>\n<pre><code class=\"language-js\">describe('tests', async () => {\n  afterEach(() => console.log('finished running a test'));\n  it('is a subtest', () => {\n    assert.ok('some relevant assertion here');\n  });\n});\n</code></pre>"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `MockFunctionContext`",
          "type": "class",
          "name": "MockFunctionContext",
          "meta": {
            "added": [
              "v19.1.0",
              "v18.13.0"
            ],
            "changes": []
          },
          "desc": "<p>The <code>MockFunctionContext</code> class is used to inspect or manipulate the behavior of\nmocks created via the <a href=\"#class-mocktracker\"><code>MockTracker</code></a> APIs.</p>",
          "properties": [
            {
              "textRaw": "`calls` {Array}",
              "type": "Array",
              "name": "calls",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "desc": "<p>A getter that returns a copy of the internal array used to track calls to the\nmock. Each entry in the array is an object with the following properties.</p>\n<ul>\n<li><code>arguments</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\" class=\"type\">&lt;Array&gt;</a> An array of the arguments passed to the mock function.</li>\n<li><code>error</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types\" class=\"type\">&lt;any&gt;</a> If the mocked function threw then this property contains the\nthrown value. <strong>Default:</strong> <code>undefined</code>.</li>\n<li><code>result</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types\" class=\"type\">&lt;any&gt;</a> The value returned by the mocked function.</li>\n<li><code>stack</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\">&lt;Error&gt;</a> An <code>Error</code> object whose stack can be used to determine the\ncallsite of the mocked function invocation.</li>\n<li><code>target</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\">&lt;Function&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type\" class=\"type\">&lt;undefined&gt;</a> If the mocked function is a constructor, this\nfield contains the class being constructed. Otherwise this will be\n<code>undefined</code>.</li>\n<li><code>this</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types\" class=\"type\">&lt;any&gt;</a> The mocked function's <code>this</code> value.</li>\n</ul>"
            }
          ],
          "methods": [
            {
              "textRaw": "`ctx.callCount()`",
              "type": "method",
              "name": "callCount",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {integer} The number of times that this mock has been invoked.",
                    "name": "return",
                    "type": "integer",
                    "desc": "The number of times that this mock has been invoked."
                  },
                  "params": []
                }
              ],
              "desc": "<p>This function returns the number of times that this mock has been invoked. This\nfunction is more efficient than checking <code>ctx.calls.length</code> because <code>ctx.calls</code>\nis a getter that creates a copy of the internal call tracking array.</p>"
            },
            {
              "textRaw": "`ctx.mockImplementation(implementation)`",
              "type": "method",
              "name": "mockImplementation",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} The function to be used as the mock's new implementation.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "desc": "The function to be used as the mock's new implementation."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to change the behavior of an existing mock.</p>\n<p>The following example creates a mock function using <code>t.mock.fn()</code>, calls the\nmock function, and then changes the mock implementation to a different function.</p>\n<pre><code class=\"language-js\">test('changes a mock behavior', (t) => {\n  let cnt = 0;\n\n  function addOne() {\n    cnt++;\n    return cnt;\n  }\n\n  function addTwo() {\n    cnt += 2;\n    return cnt;\n  }\n\n  const fn = t.mock.fn(addOne);\n\n  assert.strictEqual(fn(), 1);\n  fn.mock.mockImplementation(addTwo);\n  assert.strictEqual(fn(), 3);\n  assert.strictEqual(fn(), 5);\n});\n</code></pre>"
            },
            {
              "textRaw": "`ctx.mockImplementationOnce(implementation[, onCall])`",
              "type": "method",
              "name": "mockImplementationOnce",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} The function to be used as the mock's implementation for the invocation number specified by `onCall`.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "desc": "The function to be used as the mock's implementation for the invocation number specified by `onCall`."
                    },
                    {
                      "textRaw": "`onCall` {integer} The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown. **Default:** The number of the next invocation.",
                      "name": "onCall",
                      "type": "integer",
                      "default": "The number of the next invocation",
                      "desc": "The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to change the behavior of an existing mock for a single\ninvocation. Once invocation <code>onCall</code> has occurred, the mock will revert to\nwhatever behavior it would have used had <code>mockImplementationOnce()</code> not been\ncalled.</p>\n<p>The following example creates a mock function using <code>t.mock.fn()</code>, calls the\nmock function, changes the mock implementation to a different function for the\nnext invocation, and then resumes its previous behavior.</p>\n<pre><code class=\"language-js\">test('changes a mock behavior once', (t) => {\n  let cnt = 0;\n\n  function addOne() {\n    cnt++;\n    return cnt;\n  }\n\n  function addTwo() {\n    cnt += 2;\n    return cnt;\n  }\n\n  const fn = t.mock.fn(addOne);\n\n  assert.strictEqual(fn(), 1);\n  fn.mock.mockImplementationOnce(addTwo);\n  assert.strictEqual(fn(), 3);\n  assert.strictEqual(fn(), 4);\n});\n</code></pre>"
            },
            {
              "textRaw": "`ctx.resetCalls()`",
              "type": "method",
              "name": "resetCalls",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the call history of the mock function.</p>"
            },
            {
              "textRaw": "`ctx.restore()`",
              "type": "method",
              "name": "restore",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Resets the implementation of the mock function to its original behavior. The\nmock can still be used after calling this function.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `MockTracker`",
          "type": "class",
          "name": "MockTracker",
          "meta": {
            "added": [
              "v19.1.0",
              "v18.13.0"
            ],
            "changes": []
          },
          "desc": "<p>The <code>MockTracker</code> class is used to manage mocking functionality. The test runner\nmodule provides a top level <code>mock</code> export which is a <code>MockTracker</code> instance.\nEach test also provides its own <code>MockTracker</code> instance via the test context's\n<code>mock</code> property.</p>",
          "methods": [
            {
              "textRaw": "`mock.fn([original[, implementation]][, options])`",
              "type": "method",
              "name": "fn",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Proxy} The mocked function. The mocked function contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked function.",
                    "name": "return",
                    "type": "Proxy",
                    "desc": "The mocked function. The mocked function contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked function."
                  },
                  "params": [
                    {
                      "textRaw": "`original` {Function|AsyncFunction} An optional function to create a mock on. **Default:** A no-op function.",
                      "name": "original",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "An optional function to create a mock on."
                    },
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`. **Default:** The function specified by `original`.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "default": "The function specified by `original`",
                      "desc": "An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`."
                    },
                    {
                      "textRaw": "`options` {Object} Optional configuration options for the mock function. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Optional configuration options for the mock function. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`times` {integer} The number of times that the mock will use the behavior of `implementation`. Once the mock function has been called `times` times, it will automatically restore the behavior of `original`. This value must be an integer greater than zero. **Default:** `Infinity`.",
                          "name": "times",
                          "type": "integer",
                          "default": "`Infinity`",
                          "desc": "The number of times that the mock will use the behavior of `implementation`. Once the mock function has been called `times` times, it will automatically restore the behavior of `original`. This value must be an integer greater than zero."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a mock function.</p>\n<p>The following example creates a mock function that increments a counter by one\non each invocation. The <code>times</code> option is used to modify the mock behavior such\nthat the first two invocations add two to the counter instead of one.</p>\n<pre><code class=\"language-js\">test('mocks a counting function', (t) => {\n  let cnt = 0;\n\n  function addOne() {\n    cnt++;\n    return cnt;\n  }\n\n  function addTwo() {\n    cnt += 2;\n    return cnt;\n  }\n\n  const fn = t.mock.fn(addOne, addTwo, { times: 2 });\n\n  assert.strictEqual(fn(), 2);\n  assert.strictEqual(fn(), 4);\n  assert.strictEqual(fn(), 5);\n  assert.strictEqual(fn(), 6);\n});\n</code></pre>"
            },
            {
              "textRaw": "`mock.getter(object, methodName[, implementation][, options])`",
              "type": "method",
              "name": "getter",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function is syntax sugar for <a href=\"#mockmethodobject-methodname-implementation-options\"><code>MockTracker.method</code></a> with <code>options.getter</code>\nset to <code>true</code>.</p>"
            },
            {
              "textRaw": "`mock.method(object, methodName[, implementation][, options])`",
              "type": "method",
              "name": "method",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Proxy} The mocked method. The mocked method contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked method.",
                    "name": "return",
                    "type": "Proxy",
                    "desc": "The mocked method. The mocked method contains a special `mock` property, which is an instance of [`MockFunctionContext`][], and can be used for inspecting and changing the behavior of the mocked method."
                  },
                  "params": [
                    {
                      "textRaw": "`object` {Object} The object whose method is being mocked.",
                      "name": "object",
                      "type": "Object",
                      "desc": "The object whose method is being mocked."
                    },
                    {
                      "textRaw": "`methodName` {string|symbol} The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.",
                      "name": "methodName",
                      "type": "string|symbol",
                      "desc": "The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown."
                    },
                    {
                      "textRaw": "`implementation` {Function|AsyncFunction} An optional function used as the mock implementation for `object[methodName]`. **Default:** The original method specified by `object[methodName]`.",
                      "name": "implementation",
                      "type": "Function|AsyncFunction",
                      "default": "The original method specified by `object[methodName]`",
                      "desc": "An optional function used as the mock implementation for `object[methodName]`."
                    },
                    {
                      "textRaw": "`options` {Object} Optional configuration options for the mock method. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Optional configuration options for the mock method. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`getter` {boolean} If `true`, `object[methodName]` is treated as a getter. This option cannot be used with the `setter` option. **Default:** false.",
                          "name": "getter",
                          "type": "boolean",
                          "default": "false",
                          "desc": "If `true`, `object[methodName]` is treated as a getter. This option cannot be used with the `setter` option."
                        },
                        {
                          "textRaw": "`setter` {boolean} If `true`, `object[methodName]` is treated as a setter. This option cannot be used with the `getter` option. **Default:** false.",
                          "name": "setter",
                          "type": "boolean",
                          "default": "false",
                          "desc": "If `true`, `object[methodName]` is treated as a setter. This option cannot be used with the `getter` option."
                        },
                        {
                          "textRaw": "`times` {integer} The number of times that the mock will use the behavior of `implementation`. Once the mocked method has been called `times` times, it will automatically restore the original behavior. This value must be an integer greater than zero. **Default:** `Infinity`.",
                          "name": "times",
                          "type": "integer",
                          "default": "`Infinity`",
                          "desc": "The number of times that the mock will use the behavior of `implementation`. Once the mocked method has been called `times` times, it will automatically restore the original behavior. This value must be an integer greater than zero."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a mock on an existing object method. The\nfollowing example demonstrates how a mock is created on an existing object\nmethod.</p>\n<pre><code class=\"language-js\">test('spies on an object method', (t) => {\n  const number = {\n    value: 5,\n    subtract(a) {\n      return this.value - a;\n    },\n  };\n\n  t.mock.method(number, 'subtract');\n  assert.strictEqual(number.subtract.mock.calls.length, 0);\n  assert.strictEqual(number.subtract(3), 2);\n  assert.strictEqual(number.subtract.mock.calls.length, 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.reset()`",
              "type": "method",
              "name": "reset",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function restores the default behavior of all mocks that were previously\ncreated by this <code>MockTracker</code> and disassociates the mocks from the\n<code>MockTracker</code> instance. Once disassociated, the mocks can still be used, but the\n<code>MockTracker</code> instance can no longer be used to reset their behavior or\notherwise interact with them.</p>\n<p>After each test completes, this function is called on the test context's\n<code>MockTracker</code>. If the global <code>MockTracker</code> is used extensively, calling this\nfunction manually is recommended.</p>"
            },
            {
              "textRaw": "`mock.restoreAll()`",
              "type": "method",
              "name": "restoreAll",
              "meta": {
                "added": [
                  "v19.1.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function restores the default behavior of all mocks that were previously\ncreated by this <code>MockTracker</code>. Unlike <code>mock.reset()</code>, <code>mock.restoreAll()</code> does\nnot disassociate the mocks from the <code>MockTracker</code> instance.</p>"
            },
            {
              "textRaw": "`mock.setter(object, methodName[, implementation][, options])`",
              "type": "method",
              "name": "setter",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This function is syntax sugar for <a href=\"#mockmethodobject-methodname-implementation-options\"><code>MockTracker.method</code></a> with <code>options.setter</code>\nset to <code>true</code>.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `TestsStream`",
          "type": "class",
          "name": "TestsStream",
          "meta": {
            "added": [
              "v18.9.0",
              "v16.19.0"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends <a href=\"webstreams.html#class-readablestream\" class=\"type\">&lt;ReadableStream&gt;</a></li>\n</ul>\n<p>A successful call to <a href=\"#runoptions\"><code>run()</code></a> method will return a new <a href=\"test.html#class-testsstream\" class=\"type\">&lt;TestsStream&gt;</a>\nobject, streaming a series of events representing the execution of the tests.\n<code>TestsStream</code> will emit events, in the order of the tests definition</p>",
          "events": [
            {
              "textRaw": "Event: `'test:coverage'`",
              "type": "event",
              "name": "test:coverage",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`summary` {Object} An object containing the coverage report.",
                      "name": "summary",
                      "type": "Object",
                      "desc": "An object containing the coverage report.",
                      "options": [
                        {
                          "textRaw": "`files` {Array} An array of coverage reports for individual files. Each report is an object with the following schema:",
                          "name": "files",
                          "type": "Array",
                          "desc": "An array of coverage reports for individual files. Each report is an object with the following schema:",
                          "options": [
                            {
                              "textRaw": "`path` {string} The absolute path of the file.",
                              "name": "path",
                              "type": "string",
                              "desc": "The absolute path of the file."
                            },
                            {
                              "textRaw": "`totalLineCount` {number} The total number of lines.",
                              "name": "totalLineCount",
                              "type": "number",
                              "desc": "The total number of lines."
                            },
                            {
                              "textRaw": "`totalBranchCount` {number} The total number of branches.",
                              "name": "totalBranchCount",
                              "type": "number",
                              "desc": "The total number of branches."
                            },
                            {
                              "textRaw": "`totalFunctionCount` {number} The total number of functions.",
                              "name": "totalFunctionCount",
                              "type": "number",
                              "desc": "The total number of functions."
                            },
                            {
                              "textRaw": "`coveredLineCount` {number} The number of covered lines.",
                              "name": "coveredLineCount",
                              "type": "number",
                              "desc": "The number of covered lines."
                            },
                            {
                              "textRaw": "`coveredBranchCount` {number} The number of covered branches.",
                              "name": "coveredBranchCount",
                              "type": "number",
                              "desc": "The number of covered branches."
                            },
                            {
                              "textRaw": "`coveredFunctionCount` {number} The number of covered functions.",
                              "name": "coveredFunctionCount",
                              "type": "number",
                              "desc": "The number of covered functions."
                            },
                            {
                              "textRaw": "`coveredLinePercent` {number} The percentage of lines covered.",
                              "name": "coveredLinePercent",
                              "type": "number",
                              "desc": "The percentage of lines covered."
                            },
                            {
                              "textRaw": "`coveredBranchPercent` {number} The percentage of branches covered.",
                              "name": "coveredBranchPercent",
                              "type": "number",
                              "desc": "The percentage of branches covered."
                            },
                            {
                              "textRaw": "`coveredFunctionPercent` {number} The percentage of functions covered.",
                              "name": "coveredFunctionPercent",
                              "type": "number",
                              "desc": "The percentage of functions covered."
                            },
                            {
                              "textRaw": "`uncoveredLineNumbers` {Array} An array of integers representing line numbers that are uncovered.",
                              "name": "uncoveredLineNumbers",
                              "type": "Array",
                              "desc": "An array of integers representing line numbers that are uncovered."
                            }
                          ]
                        },
                        {
                          "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:diagnostic'`",
              "type": "event",
              "name": "test:diagnostic",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, undefined if test is not ran through a file.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, undefined if test is not ran through a file."
                    },
                    {
                      "textRaw": "`message` {string} The diagnostic message.",
                      "name": "message",
                      "type": "string",
                      "desc": "The diagnostic message."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when <a href=\"#contextdiagnosticmessage\"><code>context.diagnostic</code></a> is called.</p>"
            },
            {
              "textRaw": "Event: `'test:fail'`",
              "type": "event",
              "name": "test:fail",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`details` {Object} Additional execution metadata.",
                      "name": "details",
                      "type": "Object",
                      "desc": "Additional execution metadata.",
                      "options": [
                        {
                          "textRaw": "`duration` {number} The duration of the test in milliseconds.",
                          "name": "duration",
                          "type": "number",
                          "desc": "The duration of the test in milliseconds."
                        },
                        {
                          "textRaw": "`error` {Error} The error thrown by the test.",
                          "name": "error",
                          "type": "Error",
                          "desc": "The error thrown by the test."
                        }
                      ]
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, undefined if test is not ran through a file.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, undefined if test is not ran through a file."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`testNumber` {number} The ordinal number of the test.",
                      "name": "testNumber",
                      "type": "number",
                      "desc": "The ordinal number of the test."
                    },
                    {
                      "textRaw": "`todo` {string|boolean|undefined} Present if [`context.todo`][] is called",
                      "name": "todo",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.todo`][] is called"
                    },
                    {
                      "textRaw": "`skip` {string|boolean|undefined} Present if [`context.skip`][] is called",
                      "name": "skip",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.skip`][] is called"
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test fails.</p>"
            },
            {
              "textRaw": "Event: `'test:pass'`",
              "type": "event",
              "name": "test:pass",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`details` {Object} Additional execution metadata.",
                      "name": "details",
                      "type": "Object",
                      "desc": "Additional execution metadata.",
                      "options": [
                        {
                          "textRaw": "`duration` {number} The duration of the test in milliseconds.",
                          "name": "duration",
                          "type": "number",
                          "desc": "The duration of the test in milliseconds."
                        }
                      ]
                    },
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, undefined if test is not ran through a file.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, undefined if test is not ran through a file."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    },
                    {
                      "textRaw": "`testNumber` {number} The ordinal number of the test.",
                      "name": "testNumber",
                      "type": "number",
                      "desc": "The ordinal number of the test."
                    },
                    {
                      "textRaw": "`todo` {string|boolean|undefined} Present if [`context.todo`][] is called",
                      "name": "todo",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.todo`][] is called"
                    },
                    {
                      "textRaw": "`skip` {string|boolean|undefined} Present if [`context.skip`][] is called",
                      "name": "skip",
                      "type": "string|boolean|undefined",
                      "desc": "Present if [`context.skip`][] is called"
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test passes.</p>"
            },
            {
              "textRaw": "Event: `'test:plan'`",
              "type": "event",
              "name": "test:plan",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, undefined if test is not ran through a file.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, undefined if test is not ran through a file."
                    },
                    {
                      "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.</p>"
            },
            {
              "textRaw": "Event: `'test:start'`",
              "type": "event",
              "name": "test:start",
              "params": [
                {
                  "textRaw": "`data` {Object}",
                  "name": "data",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`file` {string|undefined} The path of the test file, undefined if test is not ran through a file.",
                      "name": "file",
                      "type": "string|undefined",
                      "desc": "The path of the test file, undefined if test is not ran through a file."
                    },
                    {
                      "textRaw": "`name` {string} The test name.",
                      "name": "name",
                      "type": "string",
                      "desc": "The test name."
                    },
                    {
                      "textRaw": "`nesting` {number} The nesting level of the test.",
                      "name": "nesting",
                      "type": "number",
                      "desc": "The nesting level of the test."
                    }
                  ]
                }
              ],
              "desc": "<p>Emitted when a test starts.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `TestContext`",
          "type": "class",
          "name": "TestContext",
          "meta": {
            "added": [
              "v18.0.0",
              "v16.17.0"
            ],
            "changes": []
          },
          "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.beforeEach([fn][, options])`",
              "type": "method",
              "name": "beforeEach",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the hook. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress hook."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook running\nbefore each subtest of the current test.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  t.beforeEach((t) => t.diagnostic(`about to run ${t.name}`));\n  await t.test(\n    'This is a subtest',\n    (t) => {\n      assert.ok('some relevant assertion here');\n    },\n  );\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.after([fn][, options])`",
              "type": "method",
              "name": "after",
              "meta": {
                "added": [
                  "v19.3.0",
                  "v18.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the hook. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress hook."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook that runs after the current test\nfinishes.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  t.after((t) => t.diagnostic(`finished running ${t.name}`));\n  assert.ok('some relevant assertion here');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.afterEach([fn][, options])`",
              "type": "method",
              "name": "afterEach",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The hook function. The first argument to this function is a [`TestContext`][] object. If the hook uses callbacks, the callback function is passed as the second argument."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the hook. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the hook. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress hook.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress hook."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create a hook running\nafter each subtest of the current test.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  t.afterEach((t) => t.diagnostic(`finished running ${t.name}`));\n  await t.test(\n    'This is a subtest',\n    (t) => {\n      assert.ok('some relevant assertion here');\n    },\n  );\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.diagnostic(message)`",
              "type": "method",
              "name": "diagnostic",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {string} Message to be reported.",
                      "name": "message",
                      "type": "string",
                      "desc": "Message to be reported."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to write diagnostics to the output. Any diagnostic\ninformation is included at the end of the test's results. This function does\nnot return a value.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  t.diagnostic('A diagnostic message');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.runOnly(shouldRunOnlyTests)`",
              "type": "method",
              "name": "runOnly",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`shouldRunOnlyTests` {boolean} Whether or not to run `only` tests.",
                      "name": "shouldRunOnlyTests",
                      "type": "boolean",
                      "desc": "Whether or not to run `only` tests."
                    }
                  ]
                }
              ],
              "desc": "<p>If <code>shouldRunOnlyTests</code> is truthy, the test context will only run tests that\nhave the <code>only</code> option set. Otherwise, all tests are run. If Node.js was not\nstarted with the <a href=\"cli.html#--test-only\"><code>--test-only</code></a> command-line option, this function is a\nno-op.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  // The test context can be set to run subtests with the 'only' option.\n  t.runOnly(true);\n  return Promise.all([\n    t.test('this subtest is now skipped'),\n    t.test('this subtest is run', { only: true }),\n  ]);\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.skip([message])`",
              "type": "method",
              "name": "skip",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {string} Optional skip message.",
                      "name": "message",
                      "type": "string",
                      "desc": "Optional skip message."
                    }
                  ]
                }
              ],
              "desc": "<p>This function causes the test's output to indicate the test as skipped. If\n<code>message</code> is provided, it is included in the output. Calling <code>skip()</code> does\nnot terminate execution of the test function. This function does not return a\nvalue.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  // Make sure to return here as well if the test contains additional logic.\n  t.skip('this is skipped');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.todo([message])`",
              "type": "method",
              "name": "todo",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {string} Optional `TODO` message.",
                      "name": "message",
                      "type": "string",
                      "desc": "Optional `TODO` message."
                    }
                  ]
                }
              ],
              "desc": "<p>This function adds a <code>TODO</code> directive to the test's output. If <code>message</code> is\nprovided, it is included in the output. Calling <code>todo()</code> does not terminate\nexecution of the test function. This function does not return a value.</p>\n<pre><code class=\"language-js\">test('top level test', (t) => {\n  // This test is marked as `TODO`\n  t.todo('this is a todo');\n});\n</code></pre>"
            },
            {
              "textRaw": "`context.test([name][, options][, fn])`",
              "type": "method",
              "name": "test",
              "meta": {
                "added": [
                  "v18.0.0",
                  "v16.17.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v18.8.0",
                      "v16.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/43554",
                    "description": "Add a `signal` option."
                  },
                  {
                    "version": [
                      "v18.7.0",
                      "v16.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/43505",
                    "description": "Add a `timeout` option."
                  }
                ]
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Promise} Resolved with `undefined` once the test completes.",
                    "name": "return",
                    "type": "Promise",
                    "desc": "Resolved with `undefined` once the test completes."
                  },
                  "params": [
                    {
                      "textRaw": "`name` {string} The name of the subtest, which is displayed when reporting test results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.",
                      "name": "name",
                      "type": "string",
                      "default": "The `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name",
                      "desc": "The name of the subtest, which is displayed when reporting test results."
                    },
                    {
                      "textRaw": "`options` {Object} Configuration options for the subtest. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Configuration options for the subtest. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`concurrency` {number|boolean|null} If a number is provided, then that many tests would run in parallel. If `true`, it would run all subtests in parallel. If `false`, it would only run one test at a time. If unspecified, subtests inherit this value from their parent. **Default:** `null`.",
                          "name": "concurrency",
                          "type": "number|boolean|null",
                          "default": "`null`",
                          "desc": "If a number is provided, then that many tests would run in parallel. If `true`, it would run all subtests in parallel. If `false`, it would only run one test at a time. If unspecified, subtests inherit this value from their parent."
                        },
                        {
                          "textRaw": "`only` {boolean} If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped. **Default:** `false`.",
                          "name": "only",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If truthy, and the test context is configured to run `only` tests, then this test will be run. Otherwise, the test is skipped."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} Allows aborting an in-progress test.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows aborting an in-progress test."
                        },
                        {
                          "textRaw": "`skip` {boolean|string} If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test. **Default:** `false`.",
                          "name": "skip",
                          "type": "boolean|string",
                          "default": "`false`",
                          "desc": "If truthy, the test is skipped. If a string is provided, that string is displayed in the test results as the reason for skipping the test."
                        },
                        {
                          "textRaw": "`todo` {boolean|string} If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`. **Default:** `false`.",
                          "name": "todo",
                          "type": "boolean|string",
                          "default": "`false`",
                          "desc": "If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in the test results as the reason why the test is `TODO`."
                        },
                        {
                          "textRaw": "`timeout` {number} A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent. **Default:** `Infinity`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`Infinity`",
                          "desc": "A number of milliseconds the test will fail after. If unspecified, subtests inherit this value from their parent."
                        }
                      ]
                    },
                    {
                      "textRaw": "`fn` {Function|AsyncFunction} The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument. **Default:** A no-op function.",
                      "name": "fn",
                      "type": "Function|AsyncFunction",
                      "default": "A no-op function",
                      "desc": "The function under test. The first argument to this function is a [`TestContext`][] object. If the test uses callbacks, the callback function is passed as the second argument."
                    }
                  ]
                }
              ],
              "desc": "<p>This function is used to create subtests under the current test. This function\nbehaves in the same fashion as the top level <a href=\"#testname-options-fn\"><code>test()</code></a> function.</p>\n<pre><code class=\"language-js\">test('top level test', async (t) => {\n  await t.test(\n    'This is a subtest',\n    { only: false, skip: false, concurrency: 1, todo: false },\n    (t) => {\n      assert.ok('some relevant assertion here');\n    },\n  );\n});\n</code></pre>"
            }
          ],
          "properties": [
            {
              "textRaw": "`context.name`",
              "name": "name",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the test.</p>"
            },
            {
              "textRaw": "`signal` {AbortSignal} Can be used to abort test subtasks when the test has been aborted.",
              "type": "AbortSignal",
              "name": "signal",
              "meta": {
                "added": [
                  "v18.7.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "desc": "<pre><code class=\"language-js\">test('top level test', async (t) => {\n  await fetch('some/uri', { signal: t.signal });\n});\n</code></pre>",
              "shortDesc": "Can be used to abort test subtasks when the test has been aborted."
            }
          ]
        },
        {
          "textRaw": "Class: `SuiteContext`",
          "type": "class",
          "name": "SuiteContext",
          "meta": {
            "added": [
              "v18.7.0",
              "v16.17.0"
            ],
            "changes": []
          },
          "desc": "<p>An instance of <code>SuiteContext</code> is passed to each suite function in order to\ninteract with the test runner. However, the <code>SuiteContext</code> constructor is not\nexposed as part of the API.</p>",
          "properties": [
            {
              "textRaw": "`context.name`",
              "name": "name",
              "meta": {
                "added": [
                  "v18.8.0",
                  "v16.18.0"
                ],
                "changes": []
              },
              "desc": "<p>The name of the suite.</p>"
            },
            {
              "textRaw": "`signal` {AbortSignal} Can be used to abort test subtasks when the test has been aborted.",
              "type": "AbortSignal",
              "name": "signal",
              "meta": {
                "added": [
                  "v18.7.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "shortDesc": "Can be used to abort test subtasks when the test has been aborted."
            }
          ]
        }
      ],
      "type": "module",
      "displayName": "Test runner"
    }
  ]
}