@types/node 18.18.14 → 18.19.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.
Files changed (111) hide show
  1. {node v18.18 → node v18.19}/README.md +1 -1
  2. {node v18.18/ts4.8 → node v18.19}/module.d.ts +41 -5
  3. {node v18.18 → node v18.19}/package.json +2 -2
  4. {node v18.18/ts4.8 → node v18.19}/process.d.ts +6 -0
  5. {node v18.18/ts4.8 → node v18.19}/test.d.ts +197 -58
  6. {node v18.18 → node v18.19}/tls.d.ts +12 -0
  7. {node v18.18 → node v18.19/ts4.8}/module.d.ts +41 -5
  8. {node v18.18 → node v18.19/ts4.8}/process.d.ts +6 -0
  9. {node v18.18 → node v18.19/ts4.8}/test.d.ts +197 -58
  10. {node v18.18 → node v18.19}/ts4.8/tls.d.ts +12 -0
  11. {node v18.18 → node v18.19}/ts4.8/vm.d.ts +7 -3
  12. {node v18.18 → node v18.19}/vm.d.ts +7 -3
  13. {node v18.18 → node v18.19}/LICENSE +0 -0
  14. {node v18.18 → node v18.19}/assert/strict.d.ts +0 -0
  15. {node v18.18 → node v18.19}/assert.d.ts +0 -0
  16. {node v18.18 → node v18.19}/async_hooks.d.ts +0 -0
  17. {node v18.18 → node v18.19}/buffer.d.ts +0 -0
  18. {node v18.18 → node v18.19}/child_process.d.ts +0 -0
  19. {node v18.18 → node v18.19}/cluster.d.ts +0 -0
  20. {node v18.18 → node v18.19}/console.d.ts +0 -0
  21. {node v18.18 → node v18.19}/constants.d.ts +0 -0
  22. {node v18.18 → node v18.19}/crypto.d.ts +0 -0
  23. {node v18.18 → node v18.19}/dgram.d.ts +0 -0
  24. {node v18.18 → node v18.19}/diagnostics_channel.d.ts +0 -0
  25. {node v18.18 → node v18.19}/dns/promises.d.ts +0 -0
  26. {node v18.18 → node v18.19}/dns.d.ts +0 -0
  27. {node v18.18 → node v18.19}/dom-events.d.ts +0 -0
  28. {node v18.18 → node v18.19}/domain.d.ts +0 -0
  29. {node v18.18 → node v18.19}/events.d.ts +0 -0
  30. {node v18.18 → node v18.19}/fs/promises.d.ts +0 -0
  31. {node v18.18 → node v18.19}/fs.d.ts +0 -0
  32. {node v18.18 → node v18.19}/globals.d.ts +0 -0
  33. {node v18.18 → node v18.19}/globals.global.d.ts +0 -0
  34. {node v18.18 → node v18.19}/http.d.ts +0 -0
  35. {node v18.18 → node v18.19}/http2.d.ts +0 -0
  36. {node v18.18 → node v18.19}/https.d.ts +0 -0
  37. {node v18.18 → node v18.19}/index.d.ts +0 -0
  38. {node v18.18 → node v18.19}/inspector.d.ts +0 -0
  39. {node v18.18 → node v18.19}/net.d.ts +0 -0
  40. {node v18.18 → node v18.19}/os.d.ts +0 -0
  41. {node v18.18 → node v18.19}/path.d.ts +0 -0
  42. {node v18.18 → node v18.19}/perf_hooks.d.ts +0 -0
  43. {node v18.18 → node v18.19}/punycode.d.ts +0 -0
  44. {node v18.18 → node v18.19}/querystring.d.ts +0 -0
  45. {node v18.18 → node v18.19}/readline/promises.d.ts +0 -0
  46. {node v18.18 → node v18.19}/readline.d.ts +0 -0
  47. {node v18.18 → node v18.19}/repl.d.ts +0 -0
  48. {node v18.18 → node v18.19}/stream/consumers.d.ts +0 -0
  49. {node v18.18 → node v18.19}/stream/promises.d.ts +0 -0
  50. {node v18.18 → node v18.19}/stream/web.d.ts +0 -0
  51. {node v18.18 → node v18.19}/stream.d.ts +0 -0
  52. {node v18.18 → node v18.19}/string_decoder.d.ts +0 -0
  53. {node v18.18 → node v18.19}/timers/promises.d.ts +0 -0
  54. {node v18.18 → node v18.19}/timers.d.ts +0 -0
  55. {node v18.18 → node v18.19}/trace_events.d.ts +0 -0
  56. {node v18.18 → node v18.19}/ts4.8/assert/strict.d.ts +0 -0
  57. {node v18.18 → node v18.19}/ts4.8/assert.d.ts +0 -0
  58. {node v18.18 → node v18.19}/ts4.8/async_hooks.d.ts +0 -0
  59. {node v18.18 → node v18.19}/ts4.8/buffer.d.ts +0 -0
  60. {node v18.18 → node v18.19}/ts4.8/child_process.d.ts +0 -0
  61. {node v18.18 → node v18.19}/ts4.8/cluster.d.ts +0 -0
  62. {node v18.18 → node v18.19}/ts4.8/console.d.ts +0 -0
  63. {node v18.18 → node v18.19}/ts4.8/constants.d.ts +0 -0
  64. {node v18.18 → node v18.19}/ts4.8/crypto.d.ts +0 -0
  65. {node v18.18 → node v18.19}/ts4.8/dgram.d.ts +0 -0
  66. {node v18.18 → node v18.19}/ts4.8/diagnostics_channel.d.ts +0 -0
  67. {node v18.18 → node v18.19}/ts4.8/dns/promises.d.ts +0 -0
  68. {node v18.18 → node v18.19}/ts4.8/dns.d.ts +0 -0
  69. {node v18.18 → node v18.19}/ts4.8/dom-events.d.ts +0 -0
  70. {node v18.18 → node v18.19}/ts4.8/domain.d.ts +0 -0
  71. {node v18.18 → node v18.19}/ts4.8/events.d.ts +0 -0
  72. {node v18.18 → node v18.19}/ts4.8/fs/promises.d.ts +0 -0
  73. {node v18.18 → node v18.19}/ts4.8/fs.d.ts +0 -0
  74. {node v18.18 → node v18.19}/ts4.8/globals.d.ts +0 -0
  75. {node v18.18 → node v18.19}/ts4.8/globals.global.d.ts +0 -0
  76. {node v18.18 → node v18.19}/ts4.8/http.d.ts +0 -0
  77. {node v18.18 → node v18.19}/ts4.8/http2.d.ts +0 -0
  78. {node v18.18 → node v18.19}/ts4.8/https.d.ts +0 -0
  79. {node v18.18 → node v18.19}/ts4.8/index.d.ts +0 -0
  80. {node v18.18 → node v18.19}/ts4.8/inspector.d.ts +0 -0
  81. {node v18.18 → node v18.19}/ts4.8/net.d.ts +0 -0
  82. {node v18.18 → node v18.19}/ts4.8/os.d.ts +0 -0
  83. {node v18.18 → node v18.19}/ts4.8/path.d.ts +0 -0
  84. {node v18.18 → node v18.19}/ts4.8/perf_hooks.d.ts +0 -0
  85. {node v18.18 → node v18.19}/ts4.8/punycode.d.ts +0 -0
  86. {node v18.18 → node v18.19}/ts4.8/querystring.d.ts +0 -0
  87. {node v18.18 → node v18.19}/ts4.8/readline/promises.d.ts +0 -0
  88. {node v18.18 → node v18.19}/ts4.8/readline.d.ts +0 -0
  89. {node v18.18 → node v18.19}/ts4.8/repl.d.ts +0 -0
  90. {node v18.18 → node v18.19}/ts4.8/stream/consumers.d.ts +0 -0
  91. {node v18.18 → node v18.19}/ts4.8/stream/promises.d.ts +0 -0
  92. {node v18.18 → node v18.19}/ts4.8/stream/web.d.ts +0 -0
  93. {node v18.18 → node v18.19}/ts4.8/stream.d.ts +0 -0
  94. {node v18.18 → node v18.19}/ts4.8/string_decoder.d.ts +0 -0
  95. {node v18.18 → node v18.19}/ts4.8/timers/promises.d.ts +0 -0
  96. {node v18.18 → node v18.19}/ts4.8/timers.d.ts +0 -0
  97. {node v18.18 → node v18.19}/ts4.8/trace_events.d.ts +0 -0
  98. {node v18.18 → node v18.19}/ts4.8/tty.d.ts +0 -0
  99. {node v18.18 → node v18.19}/ts4.8/url.d.ts +0 -0
  100. {node v18.18 → node v18.19}/ts4.8/util.d.ts +0 -0
  101. {node v18.18 → node v18.19}/ts4.8/v8.d.ts +0 -0
  102. {node v18.18 → node v18.19}/ts4.8/wasi.d.ts +0 -0
  103. {node v18.18 → node v18.19}/ts4.8/worker_threads.d.ts +0 -0
  104. {node v18.18 → node v18.19}/ts4.8/zlib.d.ts +0 -0
  105. {node v18.18 → node v18.19}/tty.d.ts +0 -0
  106. {node v18.18 → node v18.19}/url.d.ts +0 -0
  107. {node v18.18 → node v18.19}/util.d.ts +0 -0
  108. {node v18.18 → node v18.19}/v8.d.ts +0 -0
  109. {node v18.18 → node v18.19}/wasi.d.ts +0 -0
  110. {node v18.18 → node v18.19}/worker_threads.d.ts +0 -0
  111. {node v18.18 → node v18.19}/zlib.d.ts +0 -0
@@ -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/v18.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 29 Nov 2023 19:35:57 GMT
11
+ * Last updated: Thu, 30 Nov 2023 20:35:52 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
@@ -120,7 +120,9 @@ declare module "module" {
120
120
  */
121
121
  findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
122
122
  }
123
- interface ImportAssertions extends NodeJS.Dict<string> {
123
+ /** @deprecated Use `ImportAttributes` instead */
124
+ interface ImportAssertions extends ImportAttributes {}
125
+ interface ImportAttributes extends NodeJS.Dict<string> {
124
126
  type?: string | undefined;
125
127
  }
126
128
  type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
@@ -129,6 +131,9 @@ declare module "module" {
129
131
  port: MessagePort;
130
132
  }
131
133
  /**
134
+ * @deprecated This hook will be removed in a future version.
135
+ * Use `initialize` instead. When a loader has an `initialize` export, `globalPreload` will be ignored.
136
+ *
132
137
  * Sometimes it might be necessary to run some code inside of the same global scope that the application runs in.
133
138
  * This hook allows the return of a string that is run as a sloppy-mode script on startup.
134
139
  *
@@ -136,15 +141,27 @@ declare module "module" {
136
141
  * @return Code to run before application startup
137
142
  */
138
143
  type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
144
+ /**
145
+ * The `initialize` hook provides a way to define a custom function that runs in the hooks thread
146
+ * when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`.
147
+ *
148
+ * This hook can receive data from a `register` invocation, including ports and other transferrable objects.
149
+ * The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes.
150
+ */
151
+ type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
139
152
  interface ResolveHookContext {
140
153
  /**
141
154
  * Export conditions of the relevant `package.json`
142
155
  */
143
156
  conditions: string[];
157
+ /**
158
+ * @deprecated Use `importAttributes` instead
159
+ */
160
+ importAssertions: ImportAttributes;
144
161
  /**
145
162
  * An object whose key-value pairs represent the assertions for the module to import
146
163
  */
147
- importAssertions: ImportAssertions;
164
+ importAttributes: ImportAttributes;
148
165
  /**
149
166
  * The module importing this one, or undefined if this is the Node.js entry point
150
167
  */
@@ -156,9 +173,13 @@ declare module "module" {
156
173
  */
157
174
  format?: ModuleFormat | null | undefined;
158
175
  /**
159
- * The import assertions to use when caching the module (optional; if excluded the input will be used)
176
+ * @deprecated Use `importAttributes` instead
160
177
  */
161
- importAssertions?: ImportAssertions | undefined;
178
+ importAssertions?: ImportAttributes | undefined;
179
+ /**
180
+ * The import attributes to use when caching the module (optional; if excluded the input will be used)
181
+ */
182
+ importAttributes?: ImportAttributes | undefined;
162
183
  /**
163
184
  * A signal that this hook intends to terminate the chain of `resolve` hooks.
164
185
  * @default false
@@ -195,10 +216,14 @@ declare module "module" {
195
216
  * The format optionally supplied by the `resolve` hook chain
196
217
  */
197
218
  format: ModuleFormat;
219
+ /**
220
+ * @deprecated Use `importAttributes` instead
221
+ */
222
+ importAssertions: ImportAttributes;
198
223
  /**
199
224
  * An object whose key-value pairs represent the assertions for the module to import
200
225
  */
201
- importAssertions: ImportAssertions;
226
+ importAttributes: ImportAttributes;
202
227
  }
203
228
  interface LoadFnOutput {
204
229
  format: ModuleFormat;
@@ -226,6 +251,11 @@ declare module "module" {
226
251
  nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>,
227
252
  ) => LoadFnOutput | Promise<LoadFnOutput>;
228
253
  }
254
+ interface RegisterOptions<Data> {
255
+ parentURL: string | URL;
256
+ data?: Data | undefined;
257
+ transferList?: any[] | undefined;
258
+ }
229
259
  interface Module extends NodeModule {}
230
260
  class Module {
231
261
  static runMain(): void;
@@ -234,6 +264,12 @@ declare module "module" {
234
264
  static builtinModules: string[];
235
265
  static isBuiltin(moduleName: string): boolean;
236
266
  static Module: typeof Module;
267
+ static register<Data = any>(
268
+ specifier: string | URL,
269
+ parentURL?: string | URL,
270
+ options?: RegisterOptions<Data>,
271
+ ): void;
272
+ static register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
237
273
  constructor(id: string, parent?: Module);
238
274
  }
239
275
  global {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.18.14",
3
+ "version": "18.19.0",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -229,7 +229,7 @@
229
229
  "dependencies": {
230
230
  "undici-types": "~5.26.4"
231
231
  },
232
- "typesPublisherContentHash": "d5af3cf2d005a6d2962993f11359c75f5fd371f76d1dce518e1fba4d8ee748e6",
232
+ "typesPublisherContentHash": "4973930634975ec1b7e1081f49fa048b7df346ef21a6dceaf5ccc8b7fe0c5a0d",
233
233
  "typeScriptVersion": "4.6",
234
234
  "nonNpm": true
235
235
  }
@@ -901,6 +901,12 @@ declare module "process" {
901
901
  * @experimental
902
902
  */
903
903
  setSourceMapsEnabled(value: boolean): void;
904
+ /**
905
+ * The `process.sourceMapsEnabled` property returns whether the [Source Map v3](https://sourcemaps.info/spec.html) support for stack traces is enabled.
906
+ * @since v18.19.0
907
+ * @experimental
908
+ */
909
+ readonly sourceMapsEnabled: boolean;
904
910
  /**
905
911
  * The `process.version` property contains the Node.js version string.
906
912
  *
@@ -148,19 +148,26 @@ declare module "node:test" {
148
148
  function only(name?: string, fn?: TestFn): Promise<void>;
149
149
  function only(options?: TestOptions, fn?: TestFn): Promise<void>;
150
150
  function only(fn?: TestFn): Promise<void>;
151
-
152
151
  /**
153
152
  * The type of a function under test. The first argument to this function is a
154
153
  * {@link TestContext} object. If the test uses callbacks, the callback function is passed as
155
154
  * the second argument.
156
155
  */
157
156
  type TestFn = (t: TestContext, done: (result?: any) => void) => any;
158
-
159
157
  /**
160
158
  * The type of a function under Suite.
161
159
  */
162
160
  type SuiteFn = (s: SuiteContext) => void | Promise<void>;
163
-
161
+ interface TestShard {
162
+ /**
163
+ * A positive integer between 1 and `<total>` that specifies the index of the shard to run.
164
+ */
165
+ index: number;
166
+ /**
167
+ * A positive integer that specifies the total number of shards to split the test files to.
168
+ */
169
+ total: number;
170
+ }
164
171
  interface RunOptions {
165
172
  /**
166
173
  * If a number is provided, then that many files would run in parallel.
@@ -170,26 +177,22 @@ declare module "node:test" {
170
177
  * @default true
171
178
  */
172
179
  concurrency?: number | boolean | undefined;
173
-
174
180
  /**
175
181
  * An array containing the list of files to run.
176
182
  * If unspecified, the test runner execution model will be used.
177
183
  */
178
184
  files?: readonly string[] | undefined;
179
-
180
185
  /**
181
186
  * Allows aborting an in-progress test execution.
182
187
  * @default undefined
183
188
  */
184
189
  signal?: AbortSignal | undefined;
185
-
186
190
  /**
187
191
  * A number of milliseconds the test will fail after.
188
192
  * If unspecified, subtests inherit this value from their parent.
189
193
  * @default Infinity
190
194
  */
191
195
  timeout?: number | undefined;
192
-
193
196
  /**
194
197
  * Sets inspector port of test child process.
195
198
  * If a nullish value is provided, each process gets its own port,
@@ -202,6 +205,11 @@ declare module "node:test" {
202
205
  * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run.
203
206
  */
204
207
  testNamePatterns?: string | RegExp | string[] | RegExp[];
208
+ /**
209
+ * If truthy, the test context will only run tests that have the `only` option set
210
+ * @since v18.19.0
211
+ */
212
+ only?: boolean;
205
213
  /**
206
214
  * A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run.
207
215
  */
@@ -211,6 +219,12 @@ declare module "node:test" {
211
219
  * @default false
212
220
  */
213
221
  watch?: boolean | undefined;
222
+ /**
223
+ * Running tests in a specific shard.
224
+ * @since v18.19.0
225
+ * @default undefined
226
+ */
227
+ shard?: TestShard | undefined;
214
228
  }
215
229
  class Test extends AsyncResource {
216
230
  concurrency: number;
@@ -561,7 +575,6 @@ declare module "node:test" {
561
575
  implementation?: Implementation,
562
576
  options?: MockFunctionOptions,
563
577
  ): Mock<F | Implementation>;
564
-
565
578
  /**
566
579
  * This function is used to create a mock on an existing object method.
567
580
  * @param object The object whose method is being mocked.
@@ -600,7 +613,6 @@ declare module "node:test" {
600
613
  implementation: Function,
601
614
  options: MockMethodOptions,
602
615
  ): Mock<Function>;
603
-
604
616
  /**
605
617
  * This function is syntax sugar for {@link MockTracker.method} with `options.getter` set to `true`.
606
618
  */
@@ -622,7 +634,6 @@ declare module "node:test" {
622
634
  implementation?: Implementation,
623
635
  options?: MockFunctionOptions,
624
636
  ): Mock<(() => MockedObject[MethodName]) | Implementation>;
625
-
626
637
  /**
627
638
  * This function is syntax sugar for {@link MockTracker.method} with `options.setter` set to `true`.
628
639
  */
@@ -644,7 +655,6 @@ declare module "node:test" {
644
655
  implementation?: Implementation,
645
656
  options?: MockFunctionOptions,
646
657
  ): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
647
-
648
658
  /**
649
659
  * This function restores the default behavior of all mocks that were previously created by this `MockTracker`
650
660
  * and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used,
@@ -654,12 +664,12 @@ declare module "node:test" {
654
664
  * If the global `MockTracker` is used extensively, calling this function manually is recommended.
655
665
  */
656
666
  reset(): void;
657
-
658
667
  /**
659
668
  * This function restores the default behavior of all mocks that were previously created by this `MockTracker`.
660
669
  * Unlike `mock.reset()`, `mock.restoreAll()` does not disassociate the mocks from the `MockTracker` instance.
661
670
  */
662
671
  restoreAll(): void;
672
+ timers: MockTimers;
663
673
  }
664
674
 
665
675
  const mock: MockTracker;
@@ -742,11 +752,172 @@ declare module "node:test" {
742
752
  */
743
753
  restore(): void;
744
754
  }
755
+ type Timer = "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout";
756
+ /**
757
+ * Mocking timers is a technique commonly used in software testing to simulate and
758
+ * control the behavior of timers, such as `setInterval` and `setTimeout`,
759
+ * without actually waiting for the specified time intervals.
760
+ *
761
+ * The `MockTracker` provides a top-level `timers` export
762
+ * which is a `MockTimers` instance.
763
+ * @since v18.19.0
764
+ * @experimental
765
+ */
766
+ class MockTimers {
767
+ /**
768
+ * Enables timer mocking for the specified timers.
769
+ *
770
+ * **Note:** When you enable mocking for a specific timer, its associated
771
+ * clear function will also be implicitly mocked.
772
+ *
773
+ * Example usage:
774
+ *
775
+ * ```js
776
+ * import { mock } from 'node:test';
777
+ * mock.timers.enable(['setInterval']);
778
+ * ```
779
+ *
780
+ * The above example enables mocking for the `setInterval` timer and
781
+ * implicitly mocks the `clearInterval` function. Only the `setInterval`and `clearInterval` functions from `node:timers`,`node:timers/promises`, and`globalThis` will be mocked.
782
+ *
783
+ * Alternatively, if you call `mock.timers.enable()` without any parameters:
784
+ *
785
+ * All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`)
786
+ * will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`,
787
+ * and `globalThis` will be mocked.
788
+ * @since v18.19.0
789
+ */
790
+ enable(timers?: Timer[]): void;
791
+ /**
792
+ * This function restores the default behavior of all mocks that were previously
793
+ * created by this `MockTimers` instance and disassociates the mocks
794
+ * from the `MockTracker` instance.
795
+ *
796
+ * **Note:** After each test completes, this function is called on
797
+ * the test context's `MockTracker`.
798
+ *
799
+ * ```js
800
+ * import { mock } from 'node:test';
801
+ * mock.timers.reset();
802
+ * ```
803
+ * @since v18.19.0
804
+ */
805
+ reset(): void;
806
+ /**
807
+ * Advances time for all mocked timers.
808
+ *
809
+ * **Note:** This diverges from how `setTimeout` in Node.js behaves and accepts
810
+ * only positive numbers. In Node.js, `setTimeout` with negative numbers is
811
+ * only supported for web compatibility reasons.
812
+ *
813
+ * The following example mocks a `setTimeout` function and
814
+ * by using `.tick` advances in
815
+ * time triggering all pending timers.
816
+ *
817
+ * ```js
818
+ * import assert from 'node:assert';
819
+ * import { test } from 'node:test';
820
+ *
821
+ * test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
822
+ * const fn = context.mock.fn();
823
+ *
824
+ * context.mock.timers.enable(['setTimeout']);
825
+ *
826
+ * setTimeout(fn, 9999);
827
+ *
828
+ * assert.strictEqual(fn.mock.callCount(), 0);
829
+ *
830
+ * // Advance in time
831
+ * context.mock.timers.tick(9999);
832
+ *
833
+ * assert.strictEqual(fn.mock.callCount(), 1);
834
+ * });
835
+ * ```
836
+ *
837
+ * Alternativelly, the `.tick` function can be called many times
838
+ *
839
+ * ```js
840
+ * import assert from 'node:assert';
841
+ * import { test } from 'node:test';
842
+ *
843
+ * test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
844
+ * const fn = context.mock.fn();
845
+ * context.mock.timers.enable(['setTimeout']);
846
+ * const nineSecs = 9000;
847
+ * setTimeout(fn, nineSecs);
848
+ *
849
+ * const twoSeconds = 3000;
850
+ * context.mock.timers.tick(twoSeconds);
851
+ * context.mock.timers.tick(twoSeconds);
852
+ * context.mock.timers.tick(twoSeconds);
853
+ *
854
+ * assert.strictEqual(fn.mock.callCount(), 1);
855
+ * });
856
+ * ```
857
+ * @since v18.19.0
858
+ */
859
+ tick(milliseconds: number): void;
860
+ /**
861
+ * Triggers all pending mocked timers immediately.
862
+ *
863
+ * The example below triggers all pending timers immediately,
864
+ * causing them to execute without any delay.
865
+ *
866
+ * ```js
867
+ * import assert from 'node:assert';
868
+ * import { test } from 'node:test';
869
+ *
870
+ * test('runAll functions following the given order', (context) => {
871
+ * context.mock.timers.enable(['setTimeout']);
872
+ * const results = [];
873
+ * setTimeout(() => results.push(1), 9999);
874
+ *
875
+ * // Notice that if both timers have the same timeout,
876
+ * // the order of execution is guaranteed
877
+ * setTimeout(() => results.push(3), 8888);
878
+ * setTimeout(() => results.push(2), 8888);
879
+ *
880
+ * assert.deepStrictEqual(results, []);
881
+ *
882
+ * context.mock.timers.runAll();
883
+ *
884
+ * assert.deepStrictEqual(results, [3, 2, 1]);
885
+ * });
886
+ * ```
887
+ *
888
+ * **Note:** The `runAll()` function is specifically designed for
889
+ * triggering timers in the context of timer mocking.
890
+ * It does not have any effect on real-time system
891
+ * clocks or actual timers outside of the mocking environment.
892
+ * @since v18.19.0
893
+ */
894
+ runAll(): void;
895
+ /**
896
+ * Calls {@link MockTimers.reset()}.
897
+ */
898
+ [Symbol.dispose](): void;
899
+ }
745
900
 
746
901
  export { after, afterEach, before, beforeEach, describe, it, mock, run, test, test as default };
747
902
  }
748
903
 
749
- interface DiagnosticData {
904
+ interface TestLocationInfo {
905
+ /**
906
+ * The column number where the test is defined, or
907
+ * `undefined` if the test was run through the REPL.
908
+ */
909
+ column?: number;
910
+ /**
911
+ * The path of the test file, `undefined` if test is not ran through a file.
912
+ */
913
+ file?: string;
914
+ /**
915
+ * The line number where the test is defined, or
916
+ * `undefined` if the test was run through the REPL.
917
+ */
918
+ line?: number;
919
+ }
920
+ interface DiagnosticData extends TestLocationInfo {
750
921
  /**
751
922
  * The diagnostic message.
752
923
  */
@@ -755,12 +926,8 @@ interface DiagnosticData {
755
926
  * The nesting level of the test.
756
927
  */
757
928
  nesting: number;
758
- /**
759
- * The path of the test file, undefined if test is not ran through a file.
760
- */
761
- file?: string;
762
929
  }
763
- interface TestFail {
930
+ interface TestFail extends TestLocationInfo {
764
931
  /**
765
932
  * Additional execution metadata.
766
933
  */
@@ -799,12 +966,8 @@ interface TestFail {
799
966
  * Present if `context.skip` is called.
800
967
  */
801
968
  skip?: string | boolean;
802
- /**
803
- * The path of the test file, undefined if test is not ran through a file.
804
- */
805
- file?: string;
806
969
  }
807
- interface TestPass {
970
+ interface TestPass extends TestLocationInfo {
808
971
  /**
809
972
  * Additional execution metadata.
810
973
  */
@@ -839,12 +1002,8 @@ interface TestPass {
839
1002
  * Present if `context.skip` is called.
840
1003
  */
841
1004
  skip?: string | boolean;
842
- /**
843
- * The path of the test file, undefined if test is not ran through a file.
844
- */
845
- file?: string;
846
1005
  }
847
- interface TestPlan {
1006
+ interface TestPlan extends TestLocationInfo {
848
1007
  /**
849
1008
  * The nesting level of the test.
850
1009
  */
@@ -853,12 +1012,8 @@ interface TestPlan {
853
1012
  * The number of subtests that have ran.
854
1013
  */
855
1014
  count: number;
856
- /**
857
- * The path of the test file, undefined if test is not ran through a file.
858
- */
859
- file?: string;
860
1015
  }
861
- interface TestStart {
1016
+ interface TestStart extends TestLocationInfo {
862
1017
  /**
863
1018
  * The test name.
864
1019
  */
@@ -867,54 +1022,34 @@ interface TestStart {
867
1022
  * The nesting level of the test.
868
1023
  */
869
1024
  nesting: number;
870
- /**
871
- * The path of the test file, undefined if test is not ran through a file.
872
- */
873
- file?: string;
874
1025
  }
875
- interface TestStderr {
876
- /**
877
- * The path of the test file, undefined if test is not ran through a file.
878
- */
879
- file?: string;
1026
+ interface TestStderr extends TestLocationInfo {
880
1027
  /**
881
1028
  * The message written to `stderr`
882
1029
  */
883
1030
  message: string;
884
1031
  }
885
- interface TestStdout {
886
- /**
887
- * The path of the test file, undefined if test is not ran through a file.
888
- */
889
- file?: string;
1032
+ interface TestStdout extends TestLocationInfo {
890
1033
  /**
891
1034
  * The message written to `stdout`
892
1035
  */
893
1036
  message: string;
894
1037
  }
895
- interface TestEnqueue {
1038
+ interface TestEnqueue extends TestLocationInfo {
896
1039
  /**
897
1040
  * The test name
898
1041
  */
899
1042
  name: string;
900
- /**
901
- * The path of the test file, undefined if test is not ran through a file.
902
- */
903
- file?: string;
904
1043
  /**
905
1044
  * The nesting level of the test.
906
1045
  */
907
1046
  nesting: number;
908
1047
  }
909
- interface TestDequeue {
1048
+ interface TestDequeue extends TestLocationInfo {
910
1049
  /**
911
1050
  * The test name
912
1051
  */
913
1052
  name: string;
914
- /**
915
- * The path of the test file, undefined if test is not ran through a file.
916
- */
917
- file?: string;
918
1053
  /**
919
1054
  * The nesting level of the test.
920
1055
  */
@@ -970,5 +1105,9 @@ declare module "node:test/reporters" {
970
1105
  class Spec extends Transform {
971
1106
  constructor();
972
1107
  }
973
- export { dot, Spec as spec, tap, TestEvent };
1108
+ /**
1109
+ * The `junit` reporter outputs test results in a jUnit XML format
1110
+ */
1111
+ function junit(source: TestEventGenerator): AsyncGenerator<string, void>;
1112
+ export { dot, junit, Spec as spec, tap, TestEvent };
974
1113
  }
@@ -797,6 +797,18 @@ declare module "tls" {
797
797
  }
798
798
  type SecureVersion = "TLSv1.3" | "TLSv1.2" | "TLSv1.1" | "TLSv1";
799
799
  interface SecureContextOptions {
800
+ /**
801
+ * If set, this will be called when a client opens a connection using the ALPN extension.
802
+ * One argument will be passed to the callback: an object containing `servername` and `protocols` fields,
803
+ * respectively containing the server name from the SNI extension (if any) and an array of
804
+ * ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`,
805
+ * which will be returned to the client as the selected ALPN protocol, or `undefined`,
806
+ * to reject the connection with a fatal alert. If a string is returned that does not match one of
807
+ * the client's ALPN protocols, an error will be thrown.
808
+ * This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error.
809
+ * @since v18.19.0
810
+ */
811
+ ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined;
800
812
  /**
801
813
  * Optionally override the trusted CA certificates. Default is to trust
802
814
  * the well-known CAs curated by Mozilla. Mozilla's CAs are completely