@types/node 25.3.5 → 25.5.0

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/module.d.ts CHANGED
@@ -383,59 +383,18 @@ declare module "node:module" {
383
383
  | "module-typescript"
384
384
  | "wasm";
385
385
  type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
386
- /**
387
- * The `initialize` hook provides a way to define a custom function that runs in
388
- * the hooks thread when the hooks module is initialized. Initialization happens
389
- * when the hooks module is registered via {@link register}.
390
- *
391
- * This hook can receive data from a {@link register} invocation, including
392
- * ports and other transferable objects. The return value of `initialize` can be a
393
- * `Promise`, in which case it will be awaited before the main application thread
394
- * execution resumes.
395
- */
396
386
  type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
397
387
  interface ResolveHookContext {
398
- /**
399
- * Export conditions of the relevant `package.json`
400
- */
401
388
  conditions: string[];
402
- /**
403
- * An object whose key-value pairs represent the assertions for the module to import
404
- */
405
389
  importAttributes: ImportAttributes;
406
- /**
407
- * The module importing this one, or undefined if this is the Node.js entry point
408
- */
409
390
  parentURL: string | undefined;
410
391
  }
411
392
  interface ResolveFnOutput {
412
- /**
413
- * A hint to the load hook (it might be ignored); can be an intermediary value.
414
- */
415
393
  format?: string | null | undefined;
416
- /**
417
- * The import attributes to use when caching the module (optional; if excluded the input will be used)
418
- */
419
394
  importAttributes?: ImportAttributes | undefined;
420
- /**
421
- * A signal that this hook intends to terminate the chain of `resolve` hooks.
422
- * @default false
423
- */
424
395
  shortCircuit?: boolean | undefined;
425
- /**
426
- * The absolute URL to which this input resolves
427
- */
428
396
  url: string;
429
397
  }
430
- /**
431
- * The `resolve` hook chain is responsible for telling Node.js where to find and
432
- * how to cache a given `import` statement or expression, or `require` call. It can
433
- * optionally return a format (such as `'module'`) as a hint to the `load` hook. If
434
- * a format is specified, the `load` hook is ultimately responsible for providing
435
- * the final `format` value (and it is free to ignore the hint provided by
436
- * `resolve`); if `resolve` provides a `format`, a custom `load` hook is required
437
- * even if only to pass the value to the Node.js default `load` hook.
438
- */
439
398
  type ResolveHook = (
440
399
  specifier: string,
441
400
  context: ResolveHookContext,
@@ -453,36 +412,15 @@ declare module "node:module" {
453
412
  ) => ResolveFnOutput,
454
413
  ) => ResolveFnOutput;
455
414
  interface LoadHookContext {
456
- /**
457
- * Export conditions of the relevant `package.json`
458
- */
459
415
  conditions: string[];
460
- /**
461
- * The format optionally supplied by the `resolve` hook chain (can be an intermediary value).
462
- */
463
416
  format: string | null | undefined;
464
- /**
465
- * An object whose key-value pairs represent the assertions for the module to import
466
- */
467
417
  importAttributes: ImportAttributes;
468
418
  }
469
419
  interface LoadFnOutput {
470
420
  format: string | null | undefined;
471
- /**
472
- * A signal that this hook intends to terminate the chain of `resolve` hooks.
473
- * @default false
474
- */
475
421
  shortCircuit?: boolean | undefined;
476
- /**
477
- * The source for Node.js to evaluate
478
- */
479
422
  source?: ModuleSource | undefined;
480
423
  }
481
- /**
482
- * The `load` hook provides a way to define a custom method of determining how a
483
- * URL should be interpreted, retrieved, and parsed. It is also in charge of
484
- * validating the import attributes.
485
- */
486
424
  type LoadHook = (
487
425
  url: string,
488
426
  context: LoadHookContext,
node/net.d.ts CHANGED
@@ -34,6 +34,10 @@ declare module "node:net" {
34
34
  readable?: boolean | undefined;
35
35
  writable?: boolean | undefined;
36
36
  signal?: AbortSignal | undefined;
37
+ noDelay?: boolean | undefined;
38
+ keepAlive?: boolean | undefined;
39
+ keepAliveInitialDelay?: number | undefined;
40
+ blockList?: BlockList | undefined;
37
41
  }
38
42
  interface OnReadOpts {
39
43
  buffer: Uint8Array | (() => Uint8Array);
@@ -52,9 +56,6 @@ declare module "node:net" {
52
56
  hints?: number | undefined;
53
57
  family?: number | undefined;
54
58
  lookup?: LookupFunction | undefined;
55
- noDelay?: boolean | undefined;
56
- keepAlive?: boolean | undefined;
57
- keepAliveInitialDelay?: number | undefined;
58
59
  /**
59
60
  * @since v18.13.0
60
61
  */
@@ -63,7 +64,6 @@ declare module "node:net" {
63
64
  * @since v18.13.0
64
65
  */
65
66
  autoSelectFamilyAttemptTimeout?: number | undefined;
66
- blockList?: BlockList | undefined;
67
67
  }
68
68
  interface IpcSocketConnectOpts {
69
69
  path: string;
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "25.3.5",
3
+ "version": "25.5.0",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -150,6 +150,6 @@
150
150
  "undici-types": "~7.18.0"
151
151
  },
152
152
  "peerDependencies": {},
153
- "typesPublisherContentHash": "22c44355b1dc72e34145206d9f3ca29694595f79753d2c0c29fb61d5f78f9401",
153
+ "typesPublisherContentHash": "4b6968335abe1dc64bd6086fd546d6e9c50f986c37d49de8073f4ed1c900057c",
154
154
  "typeScriptVersion": "5.2"
155
155
  }
node/process.d.ts CHANGED
@@ -729,7 +729,8 @@ declare module "node:process" {
729
729
  * arguments passed when the Node.js process was launched. The first element will
730
730
  * be {@link execPath}. See `process.argv0` if access to the original value
731
731
  * of `argv[0]` is needed. The second element will be the path to the JavaScript
732
- * file being executed. The remaining elements will be any additional command-line
732
+ * file being executed. If a [program entry point](https://nodejs.org/docs/latest-v25.x/api/cli.html#program-entry-point) was provided, the second element
733
+ * will be the absolute path to it. The remaining elements are additional command-line
733
734
  * arguments.
734
735
  *
735
736
  * For example, assuming the following script for `process-args.js`:
@@ -1861,6 +1862,24 @@ declare module "node:process" {
1861
1862
  */
1862
1863
  readonly release: ProcessRelease;
1863
1864
  readonly features: ProcessFeatures;
1865
+ /**
1866
+ * The `process.traceProcessWarnings` property indicates whether the `--trace-warnings` flag
1867
+ * is set on the current Node.js process. This property allows programmatic control over the
1868
+ * tracing of warnings, enabling or disabling stack traces for warnings at runtime.
1869
+ *
1870
+ * ```js
1871
+ * // Enable trace warnings
1872
+ * process.traceProcessWarnings = true;
1873
+ *
1874
+ * // Emit a warning with a stack trace
1875
+ * process.emitWarning('Warning with stack trace');
1876
+ *
1877
+ * // Disable trace warnings
1878
+ * process.traceProcessWarnings = false;
1879
+ * ```
1880
+ * @since v6.10.0
1881
+ */
1882
+ traceProcessWarnings: boolean;
1864
1883
  /**
1865
1884
  * `process.umask()` returns the Node.js process's file mode creation mask. Child
1866
1885
  * processes inherit the mask from the parent process.
node/readline.d.ts CHANGED
@@ -44,6 +44,7 @@ declare module "node:readline" {
44
44
  }
45
45
  interface InterfaceEventMap {
46
46
  "close": [];
47
+ "error": [error: Error];
47
48
  "history": [history: string[]];
48
49
  "line": [input: string];
49
50
  "pause": [];
node/sqlite.d.ts CHANGED
@@ -128,7 +128,7 @@ declare module "node:sqlite" {
128
128
  * language features that allow ordinary SQL to deliberately corrupt the database file are disabled.
129
129
  * The defensive flag can also be set using `enableDefensive()`.
130
130
  * @since v25.1.0
131
- * @default false
131
+ * @default true
132
132
  */
133
133
  defensive?: boolean | undefined;
134
134
  }
@@ -233,6 +233,28 @@ declare module "node:sqlite" {
233
233
  */
234
234
  inverse?: ((accumulator: T, ...args: SQLOutputValue[]) => T) | undefined;
235
235
  }
236
+ interface PrepareOptions {
237
+ /**
238
+ * If `true`, integer fields are read as `BigInt`s.
239
+ * @since v25.5.0
240
+ */
241
+ readBigInts?: boolean | undefined;
242
+ /**
243
+ * If `true`, results are returned as arrays.
244
+ * @since v25.5.0
245
+ */
246
+ returnArrays?: boolean | undefined;
247
+ /**
248
+ * If `true`, allows binding named parameters without the prefix character.
249
+ * @since v25.5.0
250
+ */
251
+ allowBareNamedParameters?: boolean | undefined;
252
+ /**
253
+ * If `true`, unknown named parameters are ignored.
254
+ * @since v25.5.0
255
+ */
256
+ allowUnknownNamedParameters?: boolean | undefined;
257
+ }
236
258
  /**
237
259
  * This class represents a single [connection](https://www.sqlite.org/c3ref/sqlite3.html) to a SQLite database. All APIs
238
260
  * exposed by this class execute synchronously.
@@ -425,19 +447,73 @@ declare module "node:sqlite" {
425
447
  * around [`sqlite3_prepare_v2()`](https://www.sqlite.org/c3ref/prepare.html).
426
448
  * @since v22.5.0
427
449
  * @param sql A SQL string to compile to a prepared statement.
450
+ * @param options Optional configuration for the prepared statement.
428
451
  * @return The prepared statement.
429
452
  */
430
- prepare(sql: string): StatementSync;
453
+ prepare(sql: string, options?: PrepareOptions): StatementSync;
431
454
  /**
432
- * Creates a new `SQLTagStore`, which is an LRU (Least Recently Used) cache for
433
- * storing prepared statements. This allows for the efficient reuse of prepared
434
- * statements by tagging them with a unique identifier.
455
+ * Creates a new {@link SQLTagStore}, which is a Least Recently Used (LRU) cache
456
+ * for storing prepared statements. This allows for the efficient reuse of
457
+ * prepared statements by tagging them with a unique identifier.
435
458
  *
436
459
  * When a tagged SQL literal is executed, the `SQLTagStore` checks if a prepared
437
- * statement for that specific SQL string already exists in the cache. If it does,
438
- * the cached statement is used. If not, a new prepared statement is created,
439
- * executed, and then stored in the cache for future use. This mechanism helps to
440
- * avoid the overhead of repeatedly parsing and preparing the same SQL statements.
460
+ * statement for the corresponding SQL query string already exists in the cache.
461
+ * If it does, the cached statement is used. If not, a new prepared statement is
462
+ * created, executed, and then stored in the cache for future use. This mechanism
463
+ * helps to avoid the overhead of repeatedly parsing and preparing the same SQL
464
+ * statements.
465
+ *
466
+ * Tagged statements bind the placeholder values from the template literal as
467
+ * parameters to the underlying prepared statement. For example:
468
+ *
469
+ * ```js
470
+ * sqlTagStore.get`SELECT ${value}`;
471
+ * ```
472
+ *
473
+ * is equivalent to:
474
+ *
475
+ * ```js
476
+ * db.prepare('SELECT ?').get(value);
477
+ * ```
478
+ *
479
+ * However, in the first example, the tag store will cache the underlying prepared
480
+ * statement for future use.
481
+ *
482
+ * > **Note:** The `${value}` syntax in tagged statements _binds_ a parameter to
483
+ * > the prepared statement. This differs from its behavior in _untagged_ template
484
+ * > literals, where it performs string interpolation.
485
+ * >
486
+ * > ```js
487
+ * > // This a safe example of binding a parameter to a tagged statement.
488
+ * > sqlTagStore.run`INSERT INTO t1 (id) VALUES (${id})`;
489
+ * >
490
+ * > // This is an *unsafe* example of an untagged template string.
491
+ * > // `id` is interpolated into the query text as a string.
492
+ * > // This can lead to SQL injection and data corruption.
493
+ * > db.run(`INSERT INTO t1 (id) VALUES (${id})`);
494
+ * > ```
495
+ *
496
+ * The tag store will match a statement from the cache if the query strings
497
+ * (including the positions of any bound placeholders) are identical.
498
+ *
499
+ * ```js
500
+ * // The following statements will match in the cache:
501
+ * sqlTagStore.get`SELECT * FROM t1 WHERE id = ${id} AND active = 1`;
502
+ * sqlTagStore.get`SELECT * FROM t1 WHERE id = ${12345} AND active = 1`;
503
+ *
504
+ * // The following statements will not match, as the query strings
505
+ * // and bound placeholders differ:
506
+ * sqlTagStore.get`SELECT * FROM t1 WHERE id = ${id} AND active = 1`;
507
+ * sqlTagStore.get`SELECT * FROM t1 WHERE id = 12345 AND active = 1`;
508
+ *
509
+ * // The following statements will not match, as matches are case-sensitive:
510
+ * sqlTagStore.get`SELECT * FROM t1 WHERE id = ${id} AND active = 1`;
511
+ * sqlTagStore.get`select * from t1 where id = ${id} and active = 1`;
512
+ * ```
513
+ *
514
+ * The only way of binding parameters in tagged statements is with the `${value}`
515
+ * syntax. Do not add parameter binding placeholders (`?` etc.) to the SQL query
516
+ * string itself.
441
517
  *
442
518
  * ```js
443
519
  * import { DatabaseSync } from 'node:sqlite';
@@ -453,8 +529,8 @@ declare module "node:sqlite" {
453
529
  * sql.run`INSERT INTO users VALUES (2, 'Bob')`;
454
530
  *
455
531
  * // Using the 'get' method to retrieve a single row.
456
- * const id = 1;
457
- * const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
532
+ * const name = 'Alice';
533
+ * const user = sql.get`SELECT * FROM users WHERE name = ${name}`;
458
534
  * console.log(user); // { id: 1, name: 'Alice' }
459
535
  *
460
536
  * // Using the 'all' method to retrieve all rows.
@@ -543,26 +619,39 @@ declare module "node:sqlite" {
543
619
  * [`sqlite3session_delete()`](https://www.sqlite.org/session/sqlite3session_delete.html).
544
620
  */
545
621
  close(): void;
622
+ /**
623
+ * Closes the session. If the session is already closed, does nothing.
624
+ * @since v24.9.0
625
+ */
626
+ [Symbol.dispose](): void;
546
627
  }
547
628
  /**
548
629
  * This class represents a single LRU (Least Recently Used) cache for storing
549
630
  * prepared statements.
550
631
  *
551
- * Instances of this class are created via the database.createSQLTagStore() method,
552
- * not by using a constructor. The store caches prepared statements based on the
553
- * provided SQL query string. When the same query is seen again, the store
632
+ * Instances of this class are created via the `database.createTagStore()`
633
+ * method, not by using a constructor. The store caches prepared statements based
634
+ * on the provided SQL query string. When the same query is seen again, the store
554
635
  * retrieves the cached statement and safely applies the new values through
555
636
  * parameter binding, thereby preventing attacks like SQL injection.
556
637
  *
557
638
  * The cache has a maxSize that defaults to 1000 statements, but a custom size can
558
- * be provided (e.g., database.createSQLTagStore(100)). All APIs exposed by this
639
+ * be provided (e.g., `database.createTagStore(100)`). All APIs exposed by this
559
640
  * class execute synchronously.
560
641
  * @since v24.9.0
561
642
  */
562
643
  interface SQLTagStore {
563
644
  /**
564
- * Executes the given SQL query and returns all resulting rows as an array of objects.
645
+ * Executes the given SQL query and returns all resulting rows as an array of
646
+ * objects.
647
+ *
648
+ * This function is intended to be used as a template literal tag, not to be
649
+ * called directly.
565
650
  * @since v24.9.0
651
+ * @param stringElements Template literal elements containing the SQL
652
+ * query.
653
+ * @param boundParameters Parameter values to be bound to placeholders in the template string.
654
+ * @returns An array of objects representing the rows returned by the query.
566
655
  */
567
656
  all(
568
657
  stringElements: TemplateStringsArray,
@@ -570,7 +659,15 @@ declare module "node:sqlite" {
570
659
  ): Record<string, SQLOutputValue>[];
571
660
  /**
572
661
  * Executes the given SQL query and returns the first resulting row as an object.
662
+ *
663
+ * This function is intended to be used as a template literal tag, not to be
664
+ * called directly.
573
665
  * @since v24.9.0
666
+ * @param stringElements Template literal elements containing the SQL
667
+ * query.
668
+ * @param boundParameters Parameter values to be bound to placeholders in the template string.
669
+ * @returns An object representing the first row returned by
670
+ * the query, or `undefined` if no rows are returned.
574
671
  */
575
672
  get(
576
673
  stringElements: TemplateStringsArray,
@@ -578,7 +675,14 @@ declare module "node:sqlite" {
578
675
  ): Record<string, SQLOutputValue> | undefined;
579
676
  /**
580
677
  * Executes the given SQL query and returns an iterator over the resulting rows.
678
+ *
679
+ * This function is intended to be used as a template literal tag, not to be
680
+ * called directly.
581
681
  * @since v24.9.0
682
+ * @param stringElements Template literal elements containing the SQL
683
+ * query.
684
+ * @param boundParameters Parameter values to be bound to placeholders in the template string.
685
+ * @returns An iterator that yields objects representing the rows returned by the query.
582
686
  */
583
687
  iterate(
584
688
  stringElements: TemplateStringsArray,
@@ -586,15 +690,21 @@ declare module "node:sqlite" {
586
690
  ): NodeJS.Iterator<Record<string, SQLOutputValue>>;
587
691
  /**
588
692
  * Executes the given SQL query, which is expected to not return any rows (e.g., INSERT, UPDATE, DELETE).
693
+ *
694
+ * This function is intended to be used as a template literal tag, not to be
695
+ * called directly.
589
696
  * @since v24.9.0
697
+ * @param stringElements Template literal elements containing the SQL
698
+ * query.
699
+ * @param boundParameters Parameter values to be bound to placeholders in the template string.
700
+ * @returns An object containing information about the execution, including `changes` and `lastInsertRowid`.
590
701
  */
591
702
  run(stringElements: TemplateStringsArray, ...boundParameters: SQLInputValue[]): StatementResultingChanges;
592
703
  /**
593
704
  * A read-only property that returns the number of prepared statements currently in the cache.
594
705
  * @since v24.9.0
595
- * @returns The maximum number of prepared statements the cache can hold.
596
706
  */
597
- size(): number;
707
+ readonly size: number;
598
708
  /**
599
709
  * A read-only property that returns the maximum number of prepared statements the cache can hold.
600
710
  * @since v24.9.0
node/stream.d.ts CHANGED
@@ -81,6 +81,7 @@ declare module "node:stream" {
81
81
  interface ArrayOptions extends ReadableOperatorOptions {}
82
82
  interface ReadableToWebOptions {
83
83
  strategy?: web.QueuingStrategy | undefined;
84
+ type?: web.ReadableStreamType | undefined;
84
85
  }
85
86
  interface ReadableEventMap {
86
87
  "close": [];
@@ -485,13 +486,18 @@ declare module "node:stream" {
485
486
  * }
486
487
  * }
487
488
  *
488
- * const wordsStream = Readable.from(['this is', 'compose as operator']).compose(splitToWords);
489
+ * const wordsStream = Readable.from(['text passed through', 'composed stream']).compose(splitToWords);
489
490
  * const words = await wordsStream.toArray();
490
491
  *
491
- * console.log(words); // prints ['this', 'is', 'compose', 'as', 'operator']
492
+ * console.log(words); // prints ['text', 'passed', 'through', 'composed', 'stream']
492
493
  * ```
493
494
  *
494
- * See [`stream.compose`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamcomposestreams) for more information.
495
+ * `readable.compose(s)` is equivalent to `stream.compose(readable, s)`.
496
+ *
497
+ * This method also allows for an `AbortSignal` to be provided, which will destroy
498
+ * the composed stream when aborted.
499
+ *
500
+ * See [`stream.compose(...streams)`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamcomposestreams) for more information.
495
501
  * @since v19.1.0, v18.13.0
496
502
  * @returns a stream composed with the stream `stream`.
497
503
  */
@@ -1056,6 +1062,9 @@ declare module "node:stream" {
1056
1062
  writableHighWaterMark?: number | undefined;
1057
1063
  writableCorked?: number | undefined;
1058
1064
  }
1065
+ interface DuplexToWebOptions {
1066
+ type?: web.ReadableStreamType | undefined;
1067
+ }
1059
1068
  interface DuplexEventMap extends ReadableEventMap, WritableEventMap {}
1060
1069
  /**
1061
1070
  * Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.
@@ -1109,7 +1118,7 @@ declare module "node:stream" {
1109
1118
  * A utility method for creating a web `ReadableStream` and `WritableStream` from a `Duplex`.
1110
1119
  * @since v17.0.0
1111
1120
  */
1112
- static toWeb(streamDuplex: NodeJS.ReadWriteStream): web.ReadableWritablePair;
1121
+ static toWeb(streamDuplex: NodeJS.ReadWriteStream, options?: DuplexToWebOptions): web.ReadableWritablePair;
1113
1122
  /**
1114
1123
  * A utility method for creating a `Duplex` from a web `ReadableStream` and `WritableStream`.
1115
1124
  * @since v17.0.0
@@ -1653,7 +1662,8 @@ declare module "node:stream" {
1653
1662
  * console.log(res); // prints 'HELLOWORLD'
1654
1663
  * ```
1655
1664
  *
1656
- * See [`readable.compose(stream)`](https://nodejs.org/docs/latest-v25.x/api/stream.html#readablecomposestream-options) for `stream.compose` as operator.
1665
+ * For convenience, the `readable.compose(stream)` method is available on
1666
+ * `Readable` and `Duplex` streams as a wrapper for this function.
1657
1667
  * @since v16.9.0
1658
1668
  * @experimental
1659
1669
  */
node/test.d.ts CHANGED
@@ -191,6 +191,11 @@ declare module "node:test" {
191
191
  function only(name?: string, fn?: SuiteFn): Promise<void>;
192
192
  function only(options?: TestOptions, fn?: SuiteFn): Promise<void>;
193
193
  function only(fn?: SuiteFn): Promise<void>;
194
+ // added in v25.5.0, undocumented
195
+ function expectFailure(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
196
+ function expectFailure(name?: string, fn?: SuiteFn): Promise<void>;
197
+ function expectFailure(options?: TestOptions, fn?: SuiteFn): Promise<void>;
198
+ function expectFailure(fn?: SuiteFn): Promise<void>;
194
199
  }
195
200
  /**
196
201
  * Shorthand for skipping a test. This is the same as calling {@link test} with `options.skip` set to `true`.
@@ -216,6 +221,11 @@ declare module "node:test" {
216
221
  function only(name?: string, fn?: TestFn): Promise<void>;
217
222
  function only(options?: TestOptions, fn?: TestFn): Promise<void>;
218
223
  function only(fn?: TestFn): Promise<void>;
224
+ // added in v25.5.0, undocumented
225
+ function expectFailure(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
226
+ function expectFailure(name?: string, fn?: TestFn): Promise<void>;
227
+ function expectFailure(options?: TestOptions, fn?: TestFn): Promise<void>;
228
+ function expectFailure(fn?: TestFn): Promise<void>;
219
229
  /**
220
230
  * The type of a function passed to {@link test}. The first argument to this function is a {@link TestContext} object.
221
231
  * If the test uses callbacks, the callback function is passed as the second argument.
@@ -237,7 +247,7 @@ declare module "node:test" {
237
247
  }
238
248
  interface RunOptions {
239
249
  /**
240
- * If a number is provided, then that many test processes would run in parallel, where each process corresponds to one test file.
250
+ * If a number is provided, then that many tests would run asynchronously (they are still managed by the single-threaded event loop).
241
251
  * If `true`, it would run `os.availableParallelism() - 1` test files in parallel. If `false`, it would only run one test file at a time.
242
252
  * @default false
243
253
  */
@@ -480,7 +490,7 @@ declare module "node:test" {
480
490
  }
481
491
  namespace EventData {
482
492
  interface Error extends globalThis.Error {
483
- cause: globalThis.Error;
493
+ cause: unknown;
484
494
  }
485
495
  interface LocationInfo {
486
496
  /**
@@ -969,7 +979,6 @@ declare module "node:test" {
969
979
  * @since v22.2.0, v20.15.0
970
980
  */
971
981
  readonly assert: TestContextAssert;
972
- readonly attempt: number;
973
982
  /**
974
983
  * This function is used to create a hook running before subtest of the current test.
975
984
  * @param fn The hook function. The first argument to this function is a `TestContext` object.
@@ -1032,6 +1041,21 @@ declare module "node:test" {
1032
1041
  * @since v18.8.0, v16.18.0
1033
1042
  */
1034
1043
  readonly name: string;
1044
+ /**
1045
+ * Indicated whether the test succeeded.
1046
+ * @since v21.7.0, v20.12.0
1047
+ */
1048
+ readonly passed: boolean;
1049
+ /**
1050
+ * The failure reason for the test/case; wrapped and available via `context.error.cause`.
1051
+ * @since v21.7.0, v20.12.0
1052
+ */
1053
+ readonly error: EventData.Error | null;
1054
+ /**
1055
+ * Number of times the test has been attempted.
1056
+ * @since v21.7.0, v20.12.0
1057
+ */
1058
+ readonly attempt: number;
1035
1059
  /**
1036
1060
  * This function is used to set the number of assertions and subtests that are expected to run
1037
1061
  * within the test. If the number of assertions and subtests that run does not match the
@@ -1286,6 +1310,11 @@ declare module "node:test" {
1286
1310
  * @since v22.6.0
1287
1311
  */
1288
1312
  readonly filePath: string | undefined;
1313
+ /**
1314
+ * The name of the suite and each of its ancestors, separated by `>`.
1315
+ * @since v22.3.0, v20.16.0
1316
+ */
1317
+ readonly fullName: string;
1289
1318
  /**
1290
1319
  * The name of the suite.
1291
1320
  * @since v18.8.0, v16.18.0
@@ -1345,6 +1374,8 @@ declare module "node:test" {
1345
1374
  * @since v22.2.0
1346
1375
  */
1347
1376
  plan?: number | undefined;
1377
+ // added in v25.5.0, undocumented
1378
+ expectFailure?: boolean | undefined;
1348
1379
  }
1349
1380
  /**
1350
1381
  * This function creates a hook that runs before executing a suite.
@@ -1353,7 +1384,7 @@ declare module "node:test" {
1353
1384
  * describe('tests', async () => {
1354
1385
  * before(() => console.log('about to run some test'));
1355
1386
  * it('is a subtest', () => {
1356
- * assert.ok('some relevant assertion here');
1387
+ * // Some relevant assertion here
1357
1388
  * });
1358
1389
  * });
1359
1390
  * ```
@@ -1369,7 +1400,7 @@ declare module "node:test" {
1369
1400
  * describe('tests', async () => {
1370
1401
  * after(() => console.log('finished running tests'));
1371
1402
  * it('is a subtest', () => {
1372
- * assert.ok('some relevant assertion here');
1403
+ * // Some relevant assertion here
1373
1404
  * });
1374
1405
  * });
1375
1406
  * ```
@@ -1385,7 +1416,7 @@ declare module "node:test" {
1385
1416
  * describe('tests', async () => {
1386
1417
  * beforeEach(() => console.log('about to run a test'));
1387
1418
  * it('is a subtest', () => {
1388
- * assert.ok('some relevant assertion here');
1419
+ * // Some relevant assertion here
1389
1420
  * });
1390
1421
  * });
1391
1422
  * ```
@@ -1402,7 +1433,7 @@ declare module "node:test" {
1402
1433
  * describe('tests', async () => {
1403
1434
  * afterEach(() => console.log('finished running a test'));
1404
1435
  * it('is a subtest', () => {
1405
- * assert.ok('some relevant assertion here');
1436
+ * // Some relevant assertion here
1406
1437
  * });
1407
1438
  * });
1408
1439
  * ```
@@ -2034,24 +2065,28 @@ declare module "node:test" {
2034
2065
  */
2035
2066
  enable(options?: MockTimersOptions): void;
2036
2067
  /**
2037
- * You can use the `.setTime()` method to manually move the mocked date to another time. This method only accepts a positive integer.
2038
- * Note: This method will execute any mocked timers that are in the past from the new time.
2039
- * In the below example we are setting a new time for the mocked date.
2068
+ * Sets the current Unix timestamp that will be used as reference for any mocked
2069
+ * `Date` objects.
2070
+ *
2040
2071
  * ```js
2041
2072
  * import assert from 'node:assert';
2042
2073
  * import { test } from 'node:test';
2043
- * test('sets the time of a date object', (context) => {
2044
- * // Optionally choose what to mock
2045
- * context.mock.timers.enable({ apis: ['Date'], now: 100 });
2046
- * assert.strictEqual(Date.now(), 100);
2047
- * // Advance in time will also advance the date
2048
- * context.mock.timers.setTime(1000);
2049
- * context.mock.timers.tick(200);
2050
- * assert.strictEqual(Date.now(), 1200);
2074
+ *
2075
+ * test('runAll functions following the given order', (context) => {
2076
+ * const now = Date.now();
2077
+ * const setTime = 1000;
2078
+ * // Date.now is not mocked
2079
+ * assert.deepStrictEqual(Date.now(), now);
2080
+ *
2081
+ * context.mock.timers.enable({ apis: ['Date'] });
2082
+ * context.mock.timers.setTime(setTime);
2083
+ * // Date.now is now 1000
2084
+ * assert.strictEqual(Date.now(), setTime);
2051
2085
  * });
2052
2086
  * ```
2087
+ * @since v21.2.0, v20.11.0
2053
2088
  */
2054
- setTime(time: number): void;
2089
+ setTime(milliseconds: number): void;
2055
2090
  /**
2056
2091
  * This function restores the default behavior of all mocks that were previously
2057
2092
  * created by this `MockTimers` instance and disassociates the mocks