@types/node 20.14.13 → 20.14.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node v20.14/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v20.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sun, 28 Jul 2024 10:07:16 GMT
11
+ * Last updated: Fri, 02 Aug 2024 08:37:31 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.14.13",
3
+ "version": "20.14.14",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -212,6 +212,6 @@
212
212
  "dependencies": {
213
213
  "undici-types": "~5.26.4"
214
214
  },
215
- "typesPublisherContentHash": "4054f2892d54908808ab9c26086f864bb3573f93a46c6f30c4a553b98967f156",
215
+ "typesPublisherContentHash": "1fa173001f63810587670c42eca437b8d05f603117014c56df4d43d45a8b6453",
216
216
  "typeScriptVersion": "4.8"
217
217
  }
node v20.14/test.d.ts CHANGED
@@ -80,7 +80,6 @@
80
80
  */
81
81
  declare module "node:test" {
82
82
  import { Readable } from "node:stream";
83
- import { AsyncResource } from "node:async_hooks";
84
83
  /**
85
84
  * **Note:** `shard` is used to horizontally parallelize test running across
86
85
  * machines or processes, ideal for large-scale executions across varied
@@ -98,7 +97,7 @@ declare module "node:test" {
98
97
  * .pipe(process.stdout);
99
98
  * ```
100
99
  * @since v18.9.0, v16.19.0
101
- * @param options Configuration options for running tests. The following properties are supported:
100
+ * @param options Configuration options for running tests.
102
101
  */
103
102
  function run(options?: RunOptions): TestsStream;
104
103
  /**
@@ -133,10 +132,11 @@ declare module "node:test" {
133
132
  * canceling tests because a running test might block the application thread and
134
133
  * thus prevent the scheduled cancellation.
135
134
  * @since v18.0.0, v16.17.0
136
- * @param [name='The name'] The name of the test, which is displayed when reporting test results.
137
- * @param options Configuration options for the test. The following properties are supported:
138
- * @param [fn='A no-op function'] The function under test. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the
139
- * callback function is passed as the second argument.
135
+ * @param name The name of the test, which is displayed when reporting test results.
136
+ * Defaults to the `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.
137
+ * @param options Configuration options for the test.
138
+ * @param fn The function under test. The first argument to this function is a {@link TestContext} object.
139
+ * If the test uses callbacks, the callback function is passed as the second argument.
140
140
  * @return Fulfilled with `undefined` once the test completes, or immediately if the test runs within a suite.
141
141
  */
142
142
  function test(name?: string, fn?: TestFn): Promise<void>;
@@ -148,9 +148,10 @@ declare module "node:test" {
148
148
  }
149
149
  /**
150
150
  * The `suite()` function is imported from the `node:test` module.
151
- * @param name 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.
152
- * @param options Optional configuration options for the suite. This supports the same options as `test([name][, options][, fn])`.
153
- * @param [fn='A no-op function'] The suite function declaring nested tests and suites. The first argument to this function is a `{@link SuiteContext}` object.
151
+ * @param name The name of the suite, which is displayed when reporting test results.
152
+ * Defaults to the `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.
153
+ * @param options Configuration options for the suite. This supports the same options as {@link test}.
154
+ * @param fn The suite function declaring nested tests and suites. The first argument to this function is a {@link SuiteContext} object.
154
155
  * @return Immediately fulfilled with `undefined`.
155
156
  * @since v20.13.0
156
157
  */
@@ -160,7 +161,7 @@ declare module "node:test" {
160
161
  function suite(fn?: SuiteFn): Promise<void>;
161
162
  namespace suite {
162
163
  /**
163
- * Shorthand for skipping a suite. This is the same as [`suite([name], { skip: true }[, fn])`](https://nodejs.org/docs/latest-v20.x/api/test.html#suitename-options-fn).
164
+ * Shorthand for skipping a suite. This is the same as calling {@link suite} with `options.skip` set to `true`.
164
165
  * @since v20.13.0
165
166
  */
166
167
  function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
@@ -168,7 +169,7 @@ declare module "node:test" {
168
169
  function skip(options?: TestOptions, fn?: SuiteFn): Promise<void>;
169
170
  function skip(fn?: SuiteFn): Promise<void>;
170
171
  /**
171
- * Shorthand for marking a suite as `TODO`. This is the same as [`suite([name], { todo: true }[, fn])`](https://nodejs.org/docs/latest-v20.x/api/test.html#suitename-options-fn).
172
+ * Shorthand for marking a suite as `TODO`. This is the same as calling {@link suite} with `options.todo` set to `true`.
172
173
  * @since v20.13.0
173
174
  */
174
175
  function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
@@ -176,7 +177,7 @@ declare module "node:test" {
176
177
  function todo(options?: TestOptions, fn?: SuiteFn): Promise<void>;
177
178
  function todo(fn?: SuiteFn): Promise<void>;
178
179
  /**
179
- * Shorthand for marking a suite as `only`. This is the same as [`suite([name], { only: true }[, fn])`](https://nodejs.org/docs/latest-v20.x/api/test.html#suitename-options-fn).
180
+ * Shorthand for marking a suite as `only`. This is the same as calling {@link suite} with `options.only` set to `true`.
180
181
  * @since v20.13.0
181
182
  */
182
183
  function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
@@ -185,7 +186,7 @@ declare module "node:test" {
185
186
  function only(fn?: SuiteFn): Promise<void>;
186
187
  }
187
188
  /**
188
- * Alias for `{@link suite}`.
189
+ * Alias for {@link suite}.
189
190
  *
190
191
  * The `describe()` function is imported from the `node:test` module.
191
192
  */
@@ -195,7 +196,7 @@ declare module "node:test" {
195
196
  function describe(fn?: SuiteFn): Promise<void>;
196
197
  namespace describe {
197
198
  /**
198
- * Shorthand for skipping a suite. This is the same as [`describe([name], { skip: true }[, fn])`](https://nodejs.org/docs/latest-v20.x/api/test.html#describename-options-fn).
199
+ * Shorthand for skipping a suite. This is the same as calling {@link describe} with `options.skip` set to `true`.
199
200
  * @since v18.15.0
200
201
  */
201
202
  function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
@@ -203,7 +204,7 @@ declare module "node:test" {
203
204
  function skip(options?: TestOptions, fn?: SuiteFn): Promise<void>;
204
205
  function skip(fn?: SuiteFn): Promise<void>;
205
206
  /**
206
- * Shorthand for marking a suite as `TODO`. This is the same as [`describe([name], { todo: true }[, fn])`](https://nodejs.org/docs/latest-v20.x/api/test.html#describename-options-fn).
207
+ * Shorthand for marking a suite as `TODO`. This is the same as calling {@link describe} with `options.todo` set to `true`.
207
208
  * @since v18.15.0
208
209
  */
209
210
  function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
@@ -211,7 +212,7 @@ declare module "node:test" {
211
212
  function todo(options?: TestOptions, fn?: SuiteFn): Promise<void>;
212
213
  function todo(fn?: SuiteFn): Promise<void>;
213
214
  /**
214
- * Shorthand for marking a suite as `only`. This is the same as [`describe([name], { only: true }[, fn])`](https://nodejs.org/docs/latest-v20.x/api/test.html#describename-options-fn).
215
+ * Shorthand for marking a suite as `only`. This is the same as calling {@link describe} with `options.only` set to `true`.
215
216
  * @since v18.15.0
216
217
  */
217
218
  function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
@@ -220,7 +221,7 @@ declare module "node:test" {
220
221
  function only(fn?: SuiteFn): Promise<void>;
221
222
  }
222
223
  /**
223
- * Alias for `test()`.
224
+ * Alias for {@link test}.
224
225
  *
225
226
  * The `it()` function is imported from the `node:test` module.
226
227
  * @since v18.6.0, v16.17.0
@@ -231,21 +232,21 @@ declare module "node:test" {
231
232
  function it(fn?: TestFn): Promise<void>;
232
233
  namespace it {
233
234
  /**
234
- * Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
235
+ * Shorthand for skipping a test. This is the same as calling {@link it} with `options.skip` set to `true`.
235
236
  */
236
237
  function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
237
238
  function skip(name?: string, fn?: TestFn): Promise<void>;
238
239
  function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
239
240
  function skip(fn?: TestFn): Promise<void>;
240
241
  /**
241
- * Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
242
+ * Shorthand for marking a test as `TODO`. This is the same as calling {@link it} with `options.todo` set to `true`.
242
243
  */
243
244
  function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
244
245
  function todo(name?: string, fn?: TestFn): Promise<void>;
245
246
  function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
246
247
  function todo(fn?: TestFn): Promise<void>;
247
248
  /**
248
- * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`.
249
+ * Shorthand for marking a test as `only`. This is the same as calling {@link it} with `options.only` set to `true`.
249
250
  * @since v18.15.0
250
251
  */
251
252
  function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
@@ -254,7 +255,7 @@ declare module "node:test" {
254
255
  function only(fn?: TestFn): Promise<void>;
255
256
  }
256
257
  /**
257
- * Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`.
258
+ * Shorthand for skipping a test. This is the same as calling {@link test} with `options.skip` set to `true`.
258
259
  * @since v20.2.0
259
260
  */
260
261
  function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
@@ -262,7 +263,7 @@ declare module "node:test" {
262
263
  function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
263
264
  function skip(fn?: TestFn): Promise<void>;
264
265
  /**
265
- * Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`.
266
+ * Shorthand for marking a test as `TODO`. This is the same as calling {@link test} with `options.todo` set to `true`.
266
267
  * @since v20.2.0
267
268
  */
268
269
  function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
@@ -270,7 +271,7 @@ declare module "node:test" {
270
271
  function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
271
272
  function todo(fn?: TestFn): Promise<void>;
272
273
  /**
273
- * Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`.
274
+ * Shorthand for marking a test as `only`. This is the same as calling {@link test} with `options.only` set to `true`.
274
275
  * @since v20.2.0
275
276
  */
276
277
  function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
@@ -278,18 +279,17 @@ declare module "node:test" {
278
279
  function only(options?: TestOptions, fn?: TestFn): Promise<void>;
279
280
  function only(fn?: TestFn): Promise<void>;
280
281
  /**
281
- * The type of a function under test. The first argument to this function is a
282
- * {@link TestContext} object. If the test uses callbacks, the callback function is passed as
283
- * the second argument.
282
+ * The type of a function passed to {@link test}. The first argument to this function is a {@link TestContext} object.
283
+ * If the test uses callbacks, the callback function is passed as the second argument.
284
284
  */
285
285
  type TestFn = (t: TestContext, done: (result?: any) => void) => void | Promise<void>;
286
286
  /**
287
- * The type of a function under Suite.
287
+ * The type of a suite test function. The argument to this function is a {@link SuiteContext} object.
288
288
  */
289
289
  type SuiteFn = (s: SuiteContext) => void | Promise<void>;
290
290
  interface TestShard {
291
291
  /**
292
- * A positive integer between 1 and `<total>` that specifies the index of the shard to run.
292
+ * A positive integer between 1 and `total` that specifies the index of the shard to run.
293
293
  */
294
294
  index: number;
295
295
  /**
@@ -305,7 +305,7 @@ declare module "node:test" {
305
305
  */
306
306
  concurrency?: number | boolean | undefined;
307
307
  /**
308
- * An array containing the list of files to run. **Default** matching files from
308
+ * An array containing the list of files to run. If omitted, files are run according to the
309
309
  * [test runner execution model](https://nodejs.org/docs/latest-v20.x/api/test.html#test-runner-execution-model).
310
310
  */
311
311
  files?: readonly string[] | undefined;
@@ -326,26 +326,24 @@ declare module "node:test" {
326
326
  /**
327
327
  * If truthy, the test context will only run tests that have the `only` option set
328
328
  */
329
- only?: boolean;
329
+ only?: boolean | undefined;
330
330
  /**
331
331
  * A function that accepts the `TestsStream` instance and can be used to setup listeners before any tests are run.
332
332
  * @default undefined
333
333
  */
334
- setup?: (root: Test) => void | Promise<void>;
334
+ setup?: ((reporter: TestsStream) => void | Promise<void>) | undefined;
335
335
  /**
336
336
  * Allows aborting an in-progress test execution.
337
337
  */
338
338
  signal?: AbortSignal | undefined;
339
339
  /**
340
- * A String, RegExp or a RegExp Array, that can be used to only run tests whose
341
- * name matches the provided pattern. Test name patterns are interpreted as JavaScript
342
- * regular expressions. For each test that is executed, any corresponding test hooks,
343
- * such as `beforeEach()`, are also run.
340
+ * If provided, only run tests whose name matches the provided pattern.
341
+ * Strings are interpreted as JavaScript regular expressions.
344
342
  * @default undefined
345
343
  */
346
- testNamePatterns?: string | RegExp | string[] | RegExp[];
344
+ testNamePatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
347
345
  /**
348
- * A number of milliseconds the test execution will fail after.
346
+ * The number of milliseconds after which the test execution will fail.
349
347
  * If unspecified, subtests inherit this value from their parent.
350
348
  * @default Infinity
351
349
  */
@@ -361,18 +359,8 @@ declare module "node:test" {
361
359
  */
362
360
  shard?: TestShard | undefined;
363
361
  }
364
- class Test extends AsyncResource {
365
- concurrency: number;
366
- nesting: number;
367
- only: boolean;
368
- reporter: TestsStream;
369
- runOnlySubtests: boolean;
370
- testNumber: number;
371
- timeout: number | null;
372
- }
373
362
  /**
374
- * A successful call to `run()` method will return a new `TestsStream` object, streaming a series of events representing the execution of the tests. `TestsStream` will emit events, in the
375
- * order of the tests definition
363
+ * A successful call to `run()` will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.
376
364
  *
377
365
  * Some of the events are guaranteed to be emitted in the same order as the tests are defined, while others are emitted in the order that the tests execute.
378
366
  * @since v18.9.0, v16.19.0
@@ -389,6 +377,7 @@ declare module "node:test" {
389
377
  addListener(event: "test:start", listener: (data: TestStart) => void): this;
390
378
  addListener(event: "test:stderr", listener: (data: TestStderr) => void): this;
391
379
  addListener(event: "test:stdout", listener: (data: TestStdout) => void): this;
380
+ addListener(event: "test:watch:drained", listener: () => void): this;
392
381
  addListener(event: string, listener: (...args: any[]) => void): this;
393
382
  emit(event: "test:coverage", data: TestCoverage): boolean;
394
383
  emit(event: "test:complete", data: TestComplete): boolean;
@@ -401,6 +390,7 @@ declare module "node:test" {
401
390
  emit(event: "test:start", data: TestStart): boolean;
402
391
  emit(event: "test:stderr", data: TestStderr): boolean;
403
392
  emit(event: "test:stdout", data: TestStdout): boolean;
393
+ emit(event: "test:watch:drained"): boolean;
404
394
  emit(event: string | symbol, ...args: any[]): boolean;
405
395
  on(event: "test:coverage", listener: (data: TestCoverage) => void): this;
406
396
  on(event: "test:complete", listener: (data: TestComplete) => void): this;
@@ -413,6 +403,7 @@ declare module "node:test" {
413
403
  on(event: "test:start", listener: (data: TestStart) => void): this;
414
404
  on(event: "test:stderr", listener: (data: TestStderr) => void): this;
415
405
  on(event: "test:stdout", listener: (data: TestStdout) => void): this;
406
+ on(event: "test:watch:drained", listener: () => void): this;
416
407
  on(event: string, listener: (...args: any[]) => void): this;
417
408
  once(event: "test:coverage", listener: (data: TestCoverage) => void): this;
418
409
  once(event: "test:complete", listener: (data: TestComplete) => void): this;
@@ -425,6 +416,7 @@ declare module "node:test" {
425
416
  once(event: "test:start", listener: (data: TestStart) => void): this;
426
417
  once(event: "test:stderr", listener: (data: TestStderr) => void): this;
427
418
  once(event: "test:stdout", listener: (data: TestStdout) => void): this;
419
+ once(event: "test:watch:drained", listener: () => void): this;
428
420
  once(event: string, listener: (...args: any[]) => void): this;
429
421
  prependListener(event: "test:coverage", listener: (data: TestCoverage) => void): this;
430
422
  prependListener(event: "test:complete", listener: (data: TestComplete) => void): this;
@@ -437,6 +429,7 @@ declare module "node:test" {
437
429
  prependListener(event: "test:start", listener: (data: TestStart) => void): this;
438
430
  prependListener(event: "test:stderr", listener: (data: TestStderr) => void): this;
439
431
  prependListener(event: "test:stdout", listener: (data: TestStdout) => void): this;
432
+ prependListener(event: "test:watch:drained", listener: () => void): this;
440
433
  prependListener(event: string, listener: (...args: any[]) => void): this;
441
434
  prependOnceListener(event: "test:coverage", listener: (data: TestCoverage) => void): this;
442
435
  prependOnceListener(event: "test:complete", listener: (data: TestComplete) => void): this;
@@ -449,6 +442,7 @@ declare module "node:test" {
449
442
  prependOnceListener(event: "test:start", listener: (data: TestStart) => void): this;
450
443
  prependOnceListener(event: "test:stderr", listener: (data: TestStderr) => void): this;
451
444
  prependOnceListener(event: "test:stdout", listener: (data: TestStdout) => void): this;
445
+ prependOnceListener(event: "test:watch:drained", listener: () => void): this;
452
446
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
453
447
  }
454
448
  /**
@@ -460,32 +454,28 @@ declare module "node:test" {
460
454
  class TestContext {
461
455
  /**
462
456
  * This function is used to create a hook running before subtest of the current test.
463
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
464
- * the second argument. **Default:** A no-op function.
457
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
465
458
  * @param options Configuration options for the hook.
466
459
  * @since v20.1.0
467
460
  */
468
461
  before: typeof before;
469
462
  /**
470
463
  * This function is used to create a hook running before each subtest of the current test.
471
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
472
- * the second argument. **Default:** A no-op function.
464
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
473
465
  * @param options Configuration options for the hook.
474
466
  * @since v18.8.0
475
467
  */
476
468
  beforeEach: typeof beforeEach;
477
469
  /**
478
470
  * This function is used to create a hook that runs after the current test finishes.
479
- * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as
480
- * the second argument. Default: A no-op function.
471
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
481
472
  * @param options Configuration options for the hook.
482
473
  * @since v18.13.0
483
474
  */
484
475
  after: typeof after;
485
476
  /**
486
477
  * This function is used to create a hook running after each subtest of the current test.
487
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
488
- * the second argument. **Default:** A no-op function.
478
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
489
479
  * @param options Configuration options for the hook.
490
480
  * @since v18.8.0
491
481
  */
@@ -573,11 +563,10 @@ declare module "node:test" {
573
563
  * the same fashion as the top level {@link test} function.
574
564
  * @since v18.0.0
575
565
  * @param name The name of the test, which is displayed when reporting test results.
576
- * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
577
- * @param options Configuration options for the test
578
- * @param fn The function under test. This first argument to this function is a
579
- * {@link TestContext} object. If the test uses callbacks, the callback function is
580
- * passed as the second argument. **Default:** A no-op function.
566
+ * Defaults to the `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.
567
+ * @param options Configuration options for the test.
568
+ * @param fn The function under test. This first argument to this function is a {@link TestContext} object.
569
+ * If the test uses callbacks, the callback function is passed as the second argument.
581
570
  * @returns A {@link Promise} resolved with `undefined` once the test completes.
582
571
  */
583
572
  test: typeof test;
@@ -658,8 +647,8 @@ declare module "node:test" {
658
647
  * });
659
648
  * ```
660
649
  * @since v18.8.0, v16.18.0
661
- * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
662
- * @param options Configuration options for the hook. The following properties are supported:
650
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
651
+ * @param options Configuration options for the hook.
663
652
  */
664
653
  function before(fn?: HookFn, options?: HookOptions): void;
665
654
  /**
@@ -674,8 +663,8 @@ declare module "node:test" {
674
663
  * });
675
664
  * ```
676
665
  * @since v18.8.0, v16.18.0
677
- * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
678
- * @param options Configuration options for the hook. The following properties are supported:
666
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
667
+ * @param options Configuration options for the hook.
679
668
  */
680
669
  function after(fn?: HookFn, options?: HookOptions): void;
681
670
  /**
@@ -690,8 +679,8 @@ declare module "node:test" {
690
679
  * });
691
680
  * ```
692
681
  * @since v18.8.0, v16.18.0
693
- * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
694
- * @param options Configuration options for the hook. The following properties are supported:
682
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
683
+ * @param options Configuration options for the hook.
695
684
  */
696
685
  function beforeEach(fn?: HookFn, options?: HookOptions): void;
697
686
  /**
@@ -707,8 +696,8 @@ declare module "node:test" {
707
696
  * });
708
697
  * ```
709
698
  * @since v18.8.0, v16.18.0
710
- * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
711
- * @param options Configuration options for the hook. The following properties are supported:
699
+ * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
700
+ * @param options Configuration options for the hook.
712
701
  */
713
702
  function afterEach(fn?: HookFn, options?: HookOptions): void;
714
703
  /**
@@ -798,10 +787,10 @@ declare module "node:test" {
798
787
  * });
799
788
  * ```
800
789
  * @since v19.1.0, v18.13.0
801
- * @param [original='A no-op function'] An optional function to create a mock on.
790
+ * @param original An optional function to create a mock on.
802
791
  * @param implementation 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
803
792
  * then restore the behavior of `original`.
804
- * @param options Optional configuration options for the mock function. The following properties are supported:
793
+ * @param options Optional configuration options for the mock function.
805
794
  * @return The mocked function. The mocked function contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the
806
795
  * behavior of the mocked function.
807
796
  */
@@ -843,7 +832,7 @@ declare module "node:test" {
843
832
  * @param object The object whose method is being mocked.
844
833
  * @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.
845
834
  * @param implementation An optional function used as the mock implementation for `object[methodName]`.
846
- * @param options Optional configuration options for the mock method. The following properties are supported:
835
+ * @param options Optional configuration options for the mock method.
847
836
  * @return The mocked method. The mocked method contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the
848
837
  * behavior of the mocked method.
849
838
  */
@@ -1085,7 +1074,7 @@ declare module "node:test" {
1085
1074
 
1086
1075
  interface MockTimersOptions {
1087
1076
  apis: Timer[];
1088
- now?: number | Date;
1077
+ now?: number | Date | undefined;
1089
1078
  }
1090
1079
  /**
1091
1080
  * Mocking timers is a technique commonly used in software testing to simulate and
@@ -1324,6 +1313,9 @@ declare module "node:test" {
1324
1313
  };
1325
1314
  }
1326
1315
 
1316
+ interface TestError extends Error {
1317
+ cause: Error;
1318
+ }
1327
1319
  interface TestLocationInfo {
1328
1320
  /**
1329
1321
  * The column number where the test is defined, or
@@ -1355,7 +1347,7 @@ interface TestCoverage {
1355
1347
  */
1356
1348
  summary: {
1357
1349
  /**
1358
- * An array of coverage reports for individual files. Each report is an object with the following schema:
1350
+ * An array of coverage reports for individual files.
1359
1351
  */
1360
1352
  files: Array<{
1361
1353
  /**
@@ -1415,6 +1407,19 @@ interface TestCoverage {
1415
1407
  */
1416
1408
  count: number;
1417
1409
  }>;
1410
+ /**
1411
+ * An array of branches representing branch coverage.
1412
+ */
1413
+ branches: Array<{
1414
+ /**
1415
+ * The line number where the branch is defined.
1416
+ */
1417
+ line: number;
1418
+ /**
1419
+ * The number of times the branch was taken.
1420
+ */
1421
+ count: number;
1422
+ }>;
1418
1423
  /**
1419
1424
  * An array of lines representing line numbers and the number of times they were covered.
1420
1425
  */
@@ -1498,7 +1503,7 @@ interface TestComplete extends TestLocationInfo {
1498
1503
  /**
1499
1504
  * An error wrapping the error thrown by the test if it did not pass.
1500
1505
  */
1501
- error: Error;
1506
+ error?: TestError;
1502
1507
  /**
1503
1508
  * The type of the test, used to denote whether this is a suite.
1504
1509
  */
@@ -1555,9 +1560,9 @@ interface TestFail extends TestLocationInfo {
1555
1560
  */
1556
1561
  duration_ms: number;
1557
1562
  /**
1558
- * An error wrapping the error thrown by the test if it did not pass.
1563
+ * An error wrapping the error thrown by the test.
1559
1564
  */
1560
- error: Error;
1565
+ error: TestError;
1561
1566
  /**
1562
1567
  * The type of the test, used to denote whether this is a suite.
1563
1568
  * @since v20.0.0, v19.9.0, v18.17.0
@@ -1641,13 +1646,21 @@ interface TestStart extends TestLocationInfo {
1641
1646
  */
1642
1647
  nesting: number;
1643
1648
  }
1644
- interface TestStderr extends TestLocationInfo {
1649
+ interface TestStderr {
1650
+ /**
1651
+ * The path of the test file.
1652
+ */
1653
+ file: string;
1645
1654
  /**
1646
1655
  * The message written to `stderr`.
1647
1656
  */
1648
1657
  message: string;
1649
1658
  }
1650
- interface TestStdout extends TestLocationInfo {
1659
+ interface TestStdout {
1660
+ /**
1661
+ * The path of the test file.
1662
+ */
1663
+ file: string;
1651
1664
  /**
1652
1665
  * The message written to `stdout`.
1653
1666
  */
@@ -1686,7 +1699,7 @@ declare module "node:test/reporters" {
1686
1699
  | { type: "test:start"; data: TestStart }
1687
1700
  | { type: "test:stderr"; data: TestStderr }
1688
1701
  | { type: "test:stdout"; data: TestStdout }
1689
- | { type: "test:watch:drained" };
1702
+ | { type: "test:watch:drained"; data: undefined };
1690
1703
  type TestEventGenerator = AsyncGenerator<TestEvent, void>;
1691
1704
 
1692
1705
  /**