@types/node 24.12.0 → 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 v24.12/README.md → node/README.md +2 -2
- node v24.12/assert/strict.d.ts → node/assert/strict.d.ts +5 -11
- node v24.12/assert.d.ts → node/assert.d.ts +11 -171
- node v24.12/async_hooks.d.ts → node/async_hooks.d.ts +8 -8
- node v24.12/buffer.buffer.d.ts → node/buffer.buffer.d.ts +1 -7
- node v24.12/buffer.d.ts → node/buffer.d.ts +44 -168
- node v24.12/child_process.d.ts → node/child_process.d.ts +21 -64
- node/cluster.d.ts +486 -0
- node/console.d.ts +151 -0
- node v24.12/constants.d.ts → node/constants.d.ts +3 -4
- node v24.12/crypto.d.ts → node/crypto.d.ts +287 -1639
- node v24.12/dgram.d.ts → node/dgram.d.ts +15 -51
- node v24.12/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +4 -4
- node v24.12/dns/promises.d.ts → node/dns/promises.d.ts +3 -3
- node v24.12/dns.d.ts → node/dns.d.ts +131 -132
- node v24.12/domain.d.ts → node/domain.d.ts +13 -17
- node v24.12/events.d.ts → node/events.d.ts +866 -795
- node v24.12/fs/promises.d.ts → node/fs/promises.d.ts +7 -8
- node v24.12/fs.d.ts → node/fs.d.ts +419 -455
- node v24.12/globals.d.ts → node/globals.d.ts +6 -26
- node/globals.typedarray.d.ts +101 -0
- node v24.12/http.d.ts → node/http.d.ts +310 -276
- node v24.12/http2.d.ts → node/http2.d.ts +528 -804
- node v24.12/https.d.ts → node/https.d.ts +63 -243
- node v24.12/index.d.ts → node/index.d.ts +15 -1
- node/inspector/promises.d.ts +41 -0
- node v24.12/inspector.d.ts → node/inspector.d.ts +42 -50
- node v24.12/inspector.generated.d.ts → node/inspector.generated.d.ts +572 -417
- node v24.12/module.d.ts → node/module.d.ts +47 -195
- node v24.12/net.d.ts → node/net.d.ts +68 -189
- node v24.12/os.d.ts → node/os.d.ts +6 -6
- node v24.12/package.json → node/package.json +3 -3
- node/path/posix.d.ts +8 -0
- node/path/win32.d.ts +8 -0
- node/path.d.ts +187 -0
- node/perf_hooks.d.ts +643 -0
- node v24.12/process.d.ts → node/process.d.ts +219 -127
- node v24.12/punycode.d.ts → node/punycode.d.ts +5 -5
- node v24.12/querystring.d.ts → node/querystring.d.ts +4 -4
- node/quic.d.ts +910 -0
- node v24.12/readline/promises.d.ts → node/readline/promises.d.ts +3 -3
- node v24.12/readline.d.ts → node/readline.d.ts +68 -120
- node v24.12/repl.d.ts → node/repl.d.ts +75 -98
- node v24.12/sea.d.ts → node/sea.d.ts +1 -1
- node v24.12/sqlite.d.ts → node/sqlite.d.ts +137 -30
- node v24.12/stream/consumers.d.ts → node/stream/consumers.d.ts +10 -10
- node/stream/promises.d.ts +211 -0
- node/stream/web.d.ts +296 -0
- node v24.12/stream.d.ts → node/stream.d.ts +565 -478
- node v24.12/string_decoder.d.ts → node/string_decoder.d.ts +4 -4
- node/test/reporters.d.ts +96 -0
- node v24.12/test.d.ts → node/test.d.ts +134 -199
- node v24.12/timers/promises.d.ts → node/timers/promises.d.ts +4 -4
- node v24.12/timers.d.ts → node/timers.d.ts +4 -130
- node v24.12/tls.d.ts → node/tls.d.ts +109 -179
- node v24.12/trace_events.d.ts → node/trace_events.d.ts +9 -9
- node v24.12/ts5.6/buffer.buffer.d.ts → node/ts5.6/buffer.buffer.d.ts +1 -7
- node v24.12/ts5.6/index.d.ts → node/ts5.6/index.d.ts +15 -1
- node v24.12/ts5.7/index.d.ts → node/ts5.7/index.d.ts +15 -1
- node v24.12/tty.d.ts → node/tty.d.ts +58 -16
- node/url.d.ts +541 -0
- node/util/types.d.ts +558 -0
- node v24.12/util.d.ts → node/util.d.ts +150 -796
- node v24.12/v8.d.ts → node/v8.d.ts +31 -21
- node v24.12/vm.d.ts → node/vm.d.ts +43 -30
- node v24.12/wasi.d.ts → node/wasi.d.ts +4 -4
- node v24.12/web-globals/abortcontroller.d.ts → node/web-globals/abortcontroller.d.ts +27 -2
- node/web-globals/blob.d.ts +23 -0
- node/web-globals/console.d.ts +9 -0
- node v24.12/web-globals/crypto.d.ts → node/web-globals/crypto.d.ts +7 -0
- node/web-globals/encoding.d.ts +11 -0
- node v24.12/web-globals/events.d.ts → node/web-globals/events.d.ts +9 -0
- node v24.12/web-globals/fetch.d.ts → node/web-globals/fetch.d.ts +7 -0
- node/web-globals/importmeta.d.ts +13 -0
- node/web-globals/messaging.d.ts +23 -0
- node/web-globals/performance.d.ts +45 -0
- node/web-globals/streams.d.ts +115 -0
- node/web-globals/timers.d.ts +44 -0
- node/web-globals/url.d.ts +24 -0
- node v24.12/worker_threads.d.ts → node/worker_threads.d.ts +186 -363
- node v24.12/zlib.d.ts → node/zlib.d.ts +8 -71
- node v24.12/cluster.d.ts +0 -578
- node v24.12/console.d.ts +0 -453
- node v24.12/globals.typedarray.d.ts +0 -41
- node v24.12/path.d.ts +0 -200
- node v24.12/perf_hooks.d.ts +0 -1042
- node v24.12/stream/promises.d.ts +0 -90
- node v24.12/stream/web.d.ts +0 -573
- node v24.12/url.d.ts +0 -1057
- node v24.12/web-globals/streams.d.ts +0 -22
- {node v24.12 → node}/LICENSE +0 -0
- {node v24.12 → node}/compatibility/iterators.d.ts +0 -0
- {node v24.12 → node}/ts5.6/compatibility/float16array.d.ts +0 -0
- {node v24.12 → node}/ts5.6/globals.typedarray.d.ts +0 -0
- {node v24.12 → node}/ts5.7/compatibility/float16array.d.ts +0 -0
- {node v24.12 → node}/web-globals/domexception.d.ts +0 -0
- {node v24.12 → node}/web-globals/navigator.d.ts +0 -0
- {node v24.12 → node}/web-globals/storage.d.ts +0 -0
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
* decoder.write(Buffer.from([0x82]));
|
|
37
37
|
* console.log(decoder.end(Buffer.from([0xAC]))); // Prints: €
|
|
38
38
|
* ```
|
|
39
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
39
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/string_decoder.js)
|
|
40
40
|
*/
|
|
41
|
-
declare module "string_decoder" {
|
|
41
|
+
declare module "node:string_decoder" {
|
|
42
42
|
class StringDecoder {
|
|
43
43
|
constructor(encoding?: BufferEncoding);
|
|
44
44
|
/**
|
|
@@ -62,6 +62,6 @@ declare module "string_decoder" {
|
|
|
62
62
|
end(buffer?: string | NodeJS.ArrayBufferView): string;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
declare module "
|
|
66
|
-
export * from "string_decoder";
|
|
65
|
+
declare module "string_decoder" {
|
|
66
|
+
export * from "node:string_decoder";
|
|
67
67
|
}
|
node/test/reporters.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `node:test` module supports passing `--test-reporter`
|
|
3
|
+
* flags for the test runner to use a specific reporter.
|
|
4
|
+
*
|
|
5
|
+
* The following built-reporters are supported:
|
|
6
|
+
*
|
|
7
|
+
* * `spec`
|
|
8
|
+
* The `spec` reporter outputs the test results in a human-readable format. This
|
|
9
|
+
* is the default reporter.
|
|
10
|
+
*
|
|
11
|
+
* * `tap`
|
|
12
|
+
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
|
|
13
|
+
*
|
|
14
|
+
* * `dot`
|
|
15
|
+
* The `dot` reporter outputs the test results in a compact format,
|
|
16
|
+
* where each passing test is represented by a `.`,
|
|
17
|
+
* and each failing test is represented by a `X`.
|
|
18
|
+
*
|
|
19
|
+
* * `junit`
|
|
20
|
+
* The junit reporter outputs test results in a jUnit XML format
|
|
21
|
+
*
|
|
22
|
+
* * `lcov`
|
|
23
|
+
* The `lcov` reporter outputs test coverage when used with the
|
|
24
|
+
* `--experimental-test-coverage` flag.
|
|
25
|
+
*
|
|
26
|
+
* The exact output of these reporters is subject to change between versions of
|
|
27
|
+
* Node.js, and should not be relied on programmatically. If programmatic access
|
|
28
|
+
* to the test runner's output is required, use the events emitted by the
|
|
29
|
+
* `TestsStream`.
|
|
30
|
+
*
|
|
31
|
+
* The reporters are available via the `node:test/reporters` module:
|
|
32
|
+
*
|
|
33
|
+
* ```js
|
|
34
|
+
* import { tap, spec, dot, junit, lcov } from 'node:test/reporters';
|
|
35
|
+
* ```
|
|
36
|
+
* @since v19.9.0, v18.17.0
|
|
37
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/test/reporters.js)
|
|
38
|
+
*/
|
|
39
|
+
declare module "node:test/reporters" {
|
|
40
|
+
import { Transform, TransformOptions } from "node:stream";
|
|
41
|
+
import { EventData } from "node:test";
|
|
42
|
+
type TestEvent =
|
|
43
|
+
| { type: "test:coverage"; data: EventData.TestCoverage }
|
|
44
|
+
| { type: "test:complete"; data: EventData.TestComplete }
|
|
45
|
+
| { type: "test:dequeue"; data: EventData.TestDequeue }
|
|
46
|
+
| { type: "test:diagnostic"; data: EventData.TestDiagnostic }
|
|
47
|
+
| { type: "test:enqueue"; data: EventData.TestEnqueue }
|
|
48
|
+
| { type: "test:fail"; data: EventData.TestFail }
|
|
49
|
+
| { type: "test:pass"; data: EventData.TestPass }
|
|
50
|
+
| { type: "test:plan"; data: EventData.TestPlan }
|
|
51
|
+
| { type: "test:start"; data: EventData.TestStart }
|
|
52
|
+
| { type: "test:stderr"; data: EventData.TestStderr }
|
|
53
|
+
| { type: "test:stdout"; data: EventData.TestStdout }
|
|
54
|
+
| { type: "test:summary"; data: EventData.TestSummary }
|
|
55
|
+
| { type: "test:watch:drained"; data: undefined }
|
|
56
|
+
| { type: "test:watch:restarted"; data: undefined };
|
|
57
|
+
interface ReporterConstructorWrapper<T extends new(...args: any[]) => Transform> {
|
|
58
|
+
new(...args: ConstructorParameters<T>): InstanceType<T>;
|
|
59
|
+
(...args: ConstructorParameters<T>): InstanceType<T>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The `dot` reporter outputs the test results in a compact format,
|
|
63
|
+
* where each passing test is represented by a `.`,
|
|
64
|
+
* and each failing test is represented by a `X`.
|
|
65
|
+
* @since v20.0.0
|
|
66
|
+
*/
|
|
67
|
+
function dot(source: AsyncIterable<TestEvent>): NodeJS.AsyncIterator<string>;
|
|
68
|
+
/**
|
|
69
|
+
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
|
|
70
|
+
* @since v20.0.0
|
|
71
|
+
*/
|
|
72
|
+
function tap(source: AsyncIterable<TestEvent>): NodeJS.AsyncIterator<string>;
|
|
73
|
+
class SpecReporter extends Transform {
|
|
74
|
+
constructor();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The `spec` reporter outputs the test results in a human-readable format.
|
|
78
|
+
* @since v20.0.0
|
|
79
|
+
*/
|
|
80
|
+
const spec: ReporterConstructorWrapper<typeof SpecReporter>;
|
|
81
|
+
/**
|
|
82
|
+
* The `junit` reporter outputs test results in a jUnit XML format.
|
|
83
|
+
* @since v21.0.0
|
|
84
|
+
*/
|
|
85
|
+
function junit(source: AsyncIterable<TestEvent>): NodeJS.AsyncIterator<string>;
|
|
86
|
+
class LcovReporter extends Transform {
|
|
87
|
+
constructor(options?: Omit<TransformOptions, "writableObjectMode">);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The `lcov` reporter outputs test coverage when used with the
|
|
91
|
+
* [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--experimental-test-coverage) flag.
|
|
92
|
+
* @since v22.0.0
|
|
93
|
+
*/
|
|
94
|
+
const lcov: ReporterConstructorWrapper<typeof LcovReporter>;
|
|
95
|
+
export { dot, junit, lcov, spec, tap, TestEvent };
|
|
96
|
+
}
|
|
@@ -76,11 +76,12 @@
|
|
|
76
76
|
*
|
|
77
77
|
* If any tests fail, the process exit code is set to `1`.
|
|
78
78
|
* @since v18.0.0, v16.17.0
|
|
79
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
79
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/test.js)
|
|
80
80
|
*/
|
|
81
81
|
declare module "node:test" {
|
|
82
82
|
import { AssertMethodNames } from "node:assert";
|
|
83
|
-
import { Readable } from "node:stream";
|
|
83
|
+
import { Readable, ReadableEventMap } from "node:stream";
|
|
84
|
+
import { TestEvent } from "node:test/reporters";
|
|
84
85
|
import { URL } from "node:url";
|
|
85
86
|
import TestFn = test.TestFn;
|
|
86
87
|
import TestOptions = test.TestOptions;
|
|
@@ -190,6 +191,11 @@ declare module "node:test" {
|
|
|
190
191
|
function only(name?: string, fn?: SuiteFn): Promise<void>;
|
|
191
192
|
function only(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
192
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>;
|
|
193
199
|
}
|
|
194
200
|
/**
|
|
195
201
|
* Shorthand for skipping a test. This is the same as calling {@link test} with `options.skip` set to `true`.
|
|
@@ -215,6 +221,11 @@ declare module "node:test" {
|
|
|
215
221
|
function only(name?: string, fn?: TestFn): Promise<void>;
|
|
216
222
|
function only(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
217
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>;
|
|
218
229
|
/**
|
|
219
230
|
* The type of a function passed to {@link test}. The first argument to this function is a {@link TestContext} object.
|
|
220
231
|
* If the test uses callbacks, the callback function is passed as the second argument.
|
|
@@ -236,7 +247,7 @@ declare module "node:test" {
|
|
|
236
247
|
}
|
|
237
248
|
interface RunOptions {
|
|
238
249
|
/**
|
|
239
|
-
* If a number is provided, then that many
|
|
250
|
+
* If a number is provided, then that many tests would run asynchronously (they are still managed by the single-threaded event loop).
|
|
240
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.
|
|
241
252
|
* @default false
|
|
242
253
|
*/
|
|
@@ -244,14 +255,14 @@ declare module "node:test" {
|
|
|
244
255
|
/**
|
|
245
256
|
* Specifies the current working directory to be used by the test runner.
|
|
246
257
|
* Serves as the base path for resolving files according to the
|
|
247
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
258
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
|
|
248
259
|
* @since v23.0.0
|
|
249
260
|
* @default process.cwd()
|
|
250
261
|
*/
|
|
251
262
|
cwd?: string | undefined;
|
|
252
263
|
/**
|
|
253
264
|
* An array containing the list of files to run. If omitted, files are run according to the
|
|
254
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
265
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
|
|
255
266
|
*/
|
|
256
267
|
files?: readonly string[] | undefined;
|
|
257
268
|
/**
|
|
@@ -264,7 +275,7 @@ declare module "node:test" {
|
|
|
264
275
|
/**
|
|
265
276
|
* An array containing the list of glob patterns to match test files.
|
|
266
277
|
* This option cannot be used together with `files`. If omitted, files are run according to the
|
|
267
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
278
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
|
|
268
279
|
* @since v22.6.0
|
|
269
280
|
*/
|
|
270
281
|
globPatterns?: readonly string[] | undefined;
|
|
@@ -352,7 +363,7 @@ declare module "node:test" {
|
|
|
352
363
|
*/
|
|
353
364
|
rerunFailuresFilePath?: string | undefined;
|
|
354
365
|
/**
|
|
355
|
-
* enable [code coverage](https://nodejs.org/docs/latest-
|
|
366
|
+
* enable [code coverage](https://nodejs.org/docs/latest-v25.x/api/test.html#collecting-code-coverage) collection.
|
|
356
367
|
* @since v22.10.0
|
|
357
368
|
* @default false
|
|
358
369
|
*/
|
|
@@ -399,6 +410,23 @@ declare module "node:test" {
|
|
|
399
410
|
*/
|
|
400
411
|
functionCoverage?: number | undefined;
|
|
401
412
|
}
|
|
413
|
+
interface TestsStreamEventMap extends ReadableEventMap {
|
|
414
|
+
"data": [data: TestEvent];
|
|
415
|
+
"test:coverage": [data: EventData.TestCoverage];
|
|
416
|
+
"test:complete": [data: EventData.TestComplete];
|
|
417
|
+
"test:dequeue": [data: EventData.TestDequeue];
|
|
418
|
+
"test:diagnostic": [data: EventData.TestDiagnostic];
|
|
419
|
+
"test:enqueue": [data: EventData.TestEnqueue];
|
|
420
|
+
"test:fail": [data: EventData.TestFail];
|
|
421
|
+
"test:pass": [data: EventData.TestPass];
|
|
422
|
+
"test:plan": [data: EventData.TestPlan];
|
|
423
|
+
"test:start": [data: EventData.TestStart];
|
|
424
|
+
"test:stderr": [data: EventData.TestStderr];
|
|
425
|
+
"test:stdout": [data: EventData.TestStdout];
|
|
426
|
+
"test:summary": [data: EventData.TestSummary];
|
|
427
|
+
"test:watch:drained": [];
|
|
428
|
+
"test:watch:restarted": [];
|
|
429
|
+
}
|
|
402
430
|
/**
|
|
403
431
|
* A successful call to `run()` will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.
|
|
404
432
|
*
|
|
@@ -406,100 +434,63 @@ declare module "node:test" {
|
|
|
406
434
|
* @since v18.9.0, v16.19.0
|
|
407
435
|
*/
|
|
408
436
|
interface TestsStream extends Readable {
|
|
409
|
-
|
|
410
|
-
addListener
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
addListener(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
once(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
463
|
-
once(event: "test:stderr", listener: (data: EventData.TestStderr) => void): this;
|
|
464
|
-
once(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
465
|
-
once(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
466
|
-
once(event: "test:watch:drained", listener: () => void): this;
|
|
467
|
-
once(event: "test:watch:restarted", listener: () => void): this;
|
|
468
|
-
once(event: string, listener: (...args: any[]) => void): this;
|
|
469
|
-
prependListener(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
470
|
-
prependListener(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
471
|
-
prependListener(event: "test:dequeue", listener: (data: EventData.TestDequeue) => void): this;
|
|
472
|
-
prependListener(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
473
|
-
prependListener(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
474
|
-
prependListener(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
475
|
-
prependListener(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
476
|
-
prependListener(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
477
|
-
prependListener(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
478
|
-
prependListener(event: "test:stderr", listener: (data: EventData.TestStderr) => void): this;
|
|
479
|
-
prependListener(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
480
|
-
prependListener(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
481
|
-
prependListener(event: "test:watch:drained", listener: () => void): this;
|
|
482
|
-
prependListener(event: "test:watch:restarted", listener: () => void): this;
|
|
483
|
-
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
484
|
-
prependOnceListener(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
485
|
-
prependOnceListener(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
486
|
-
prependOnceListener(event: "test:dequeue", listener: (data: EventData.TestDequeue) => void): this;
|
|
487
|
-
prependOnceListener(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
488
|
-
prependOnceListener(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
489
|
-
prependOnceListener(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
490
|
-
prependOnceListener(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
491
|
-
prependOnceListener(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
492
|
-
prependOnceListener(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
493
|
-
prependOnceListener(event: "test:stderr", listener: (data: EventData.TestStderr) => void): this;
|
|
494
|
-
prependOnceListener(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
495
|
-
prependOnceListener(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
496
|
-
prependOnceListener(event: "test:watch:drained", listener: () => void): this;
|
|
497
|
-
prependOnceListener(event: "test:watch:restarted", listener: () => void): this;
|
|
498
|
-
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
437
|
+
// #region InternalEventEmitter
|
|
438
|
+
addListener<E extends keyof TestsStreamEventMap>(
|
|
439
|
+
eventName: E,
|
|
440
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
441
|
+
): this;
|
|
442
|
+
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
443
|
+
emit<E extends keyof TestsStreamEventMap>(eventName: E, ...args: TestsStreamEventMap[E]): boolean;
|
|
444
|
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
445
|
+
listenerCount<E extends keyof TestsStreamEventMap>(
|
|
446
|
+
eventName: E,
|
|
447
|
+
listener?: (...args: TestsStreamEventMap[E]) => void,
|
|
448
|
+
): number;
|
|
449
|
+
listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
|
|
450
|
+
listeners<E extends keyof TestsStreamEventMap>(eventName: E): ((...args: TestsStreamEventMap[E]) => void)[];
|
|
451
|
+
listeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
452
|
+
off<E extends keyof TestsStreamEventMap>(
|
|
453
|
+
eventName: E,
|
|
454
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
455
|
+
): this;
|
|
456
|
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
457
|
+
on<E extends keyof TestsStreamEventMap>(
|
|
458
|
+
eventName: E,
|
|
459
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
460
|
+
): this;
|
|
461
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
462
|
+
once<E extends keyof TestsStreamEventMap>(
|
|
463
|
+
eventName: E,
|
|
464
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
465
|
+
): this;
|
|
466
|
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
467
|
+
prependListener<E extends keyof TestsStreamEventMap>(
|
|
468
|
+
eventName: E,
|
|
469
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
470
|
+
): this;
|
|
471
|
+
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
472
|
+
prependOnceListener<E extends keyof TestsStreamEventMap>(
|
|
473
|
+
eventName: E,
|
|
474
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
475
|
+
): this;
|
|
476
|
+
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
477
|
+
rawListeners<E extends keyof TestsStreamEventMap>(
|
|
478
|
+
eventName: E,
|
|
479
|
+
): ((...args: TestsStreamEventMap[E]) => void)[];
|
|
480
|
+
rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
481
|
+
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
|
482
|
+
removeAllListeners<E extends keyof TestsStreamEventMap>(eventName?: E): this;
|
|
483
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
484
|
+
removeListener<E extends keyof TestsStreamEventMap>(
|
|
485
|
+
eventName: E,
|
|
486
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
487
|
+
): this;
|
|
488
|
+
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
489
|
+
// #endregion
|
|
499
490
|
}
|
|
500
491
|
namespace EventData {
|
|
501
492
|
interface Error extends globalThis.Error {
|
|
502
|
-
cause:
|
|
493
|
+
cause: unknown;
|
|
503
494
|
}
|
|
504
495
|
interface LocationInfo {
|
|
505
496
|
/**
|
|
@@ -988,7 +979,6 @@ declare module "node:test" {
|
|
|
988
979
|
* @since v22.2.0, v20.15.0
|
|
989
980
|
*/
|
|
990
981
|
readonly assert: TestContextAssert;
|
|
991
|
-
readonly attempt: number;
|
|
992
982
|
/**
|
|
993
983
|
* This function is used to create a hook running before subtest of the current test.
|
|
994
984
|
* @param fn The hook function. The first argument to this function is a `TestContext` object.
|
|
@@ -1051,6 +1041,21 @@ declare module "node:test" {
|
|
|
1051
1041
|
* @since v18.8.0, v16.18.0
|
|
1052
1042
|
*/
|
|
1053
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;
|
|
1054
1059
|
/**
|
|
1055
1060
|
* This function is used to set the number of assertions and subtests that are expected to run
|
|
1056
1061
|
* within the test. If the number of assertions and subtests that run does not match the
|
|
@@ -1219,7 +1224,7 @@ declare module "node:test" {
|
|
|
1219
1224
|
* highlighting.
|
|
1220
1225
|
* @since v22.14.0
|
|
1221
1226
|
* @param value A value to serialize to a string. If Node.js was started with
|
|
1222
|
-
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-
|
|
1227
|
+
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--test-update-snapshots)
|
|
1223
1228
|
* flag, the serialized value is written to
|
|
1224
1229
|
* `path`. Otherwise, the serialized value is compared to the contents of the
|
|
1225
1230
|
* existing snapshot file.
|
|
@@ -1242,7 +1247,7 @@ declare module "node:test" {
|
|
|
1242
1247
|
* ```
|
|
1243
1248
|
* @since v22.3.0
|
|
1244
1249
|
* @param value A value to serialize to a string. If Node.js was started with
|
|
1245
|
-
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-
|
|
1250
|
+
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--test-update-snapshots)
|
|
1246
1251
|
* flag, the serialized value is written to
|
|
1247
1252
|
* the snapshot file. Otherwise, the serialized value is compared to the
|
|
1248
1253
|
* corresponding value in the existing snapshot file.
|
|
@@ -1305,6 +1310,11 @@ declare module "node:test" {
|
|
|
1305
1310
|
* @since v22.6.0
|
|
1306
1311
|
*/
|
|
1307
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;
|
|
1308
1318
|
/**
|
|
1309
1319
|
* The name of the suite.
|
|
1310
1320
|
* @since v18.8.0, v16.18.0
|
|
@@ -1364,6 +1374,8 @@ declare module "node:test" {
|
|
|
1364
1374
|
* @since v22.2.0
|
|
1365
1375
|
*/
|
|
1366
1376
|
plan?: number | undefined;
|
|
1377
|
+
// added in v25.5.0, undocumented
|
|
1378
|
+
expectFailure?: boolean | undefined;
|
|
1367
1379
|
}
|
|
1368
1380
|
/**
|
|
1369
1381
|
* This function creates a hook that runs before executing a suite.
|
|
@@ -1372,7 +1384,7 @@ declare module "node:test" {
|
|
|
1372
1384
|
* describe('tests', async () => {
|
|
1373
1385
|
* before(() => console.log('about to run some test'));
|
|
1374
1386
|
* it('is a subtest', () => {
|
|
1375
|
-
*
|
|
1387
|
+
* // Some relevant assertion here
|
|
1376
1388
|
* });
|
|
1377
1389
|
* });
|
|
1378
1390
|
* ```
|
|
@@ -1388,7 +1400,7 @@ declare module "node:test" {
|
|
|
1388
1400
|
* describe('tests', async () => {
|
|
1389
1401
|
* after(() => console.log('finished running tests'));
|
|
1390
1402
|
* it('is a subtest', () => {
|
|
1391
|
-
*
|
|
1403
|
+
* // Some relevant assertion here
|
|
1392
1404
|
* });
|
|
1393
1405
|
* });
|
|
1394
1406
|
* ```
|
|
@@ -1404,7 +1416,7 @@ declare module "node:test" {
|
|
|
1404
1416
|
* describe('tests', async () => {
|
|
1405
1417
|
* beforeEach(() => console.log('about to run a test'));
|
|
1406
1418
|
* it('is a subtest', () => {
|
|
1407
|
-
*
|
|
1419
|
+
* // Some relevant assertion here
|
|
1408
1420
|
* });
|
|
1409
1421
|
* });
|
|
1410
1422
|
* ```
|
|
@@ -1421,7 +1433,7 @@ declare module "node:test" {
|
|
|
1421
1433
|
* describe('tests', async () => {
|
|
1422
1434
|
* afterEach(() => console.log('finished running a test'));
|
|
1423
1435
|
* it('is a subtest', () => {
|
|
1424
|
-
*
|
|
1436
|
+
* // Some relevant assertion here
|
|
1425
1437
|
* });
|
|
1426
1438
|
* });
|
|
1427
1439
|
* ```
|
|
@@ -1673,7 +1685,7 @@ declare module "node:test" {
|
|
|
1673
1685
|
* This function is used to mock the exports of ECMAScript modules, CommonJS modules, JSON modules, and
|
|
1674
1686
|
* Node.js builtin modules. Any references to the original module prior to mocking are not impacted. In
|
|
1675
1687
|
* order to enable module mocking, Node.js must be started with the
|
|
1676
|
-
* [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-
|
|
1688
|
+
* [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--experimental-test-module-mocks)
|
|
1677
1689
|
* command-line flag.
|
|
1678
1690
|
*
|
|
1679
1691
|
* The following example demonstrates how a mock is created for a module.
|
|
@@ -2053,24 +2065,28 @@ declare module "node:test" {
|
|
|
2053
2065
|
*/
|
|
2054
2066
|
enable(options?: MockTimersOptions): void;
|
|
2055
2067
|
/**
|
|
2056
|
-
*
|
|
2057
|
-
*
|
|
2058
|
-
*
|
|
2068
|
+
* Sets the current Unix timestamp that will be used as reference for any mocked
|
|
2069
|
+
* `Date` objects.
|
|
2070
|
+
*
|
|
2059
2071
|
* ```js
|
|
2060
2072
|
* import assert from 'node:assert';
|
|
2061
2073
|
* import { test } from 'node:test';
|
|
2062
|
-
*
|
|
2063
|
-
*
|
|
2064
|
-
*
|
|
2065
|
-
*
|
|
2066
|
-
* //
|
|
2067
|
-
*
|
|
2068
|
-
*
|
|
2069
|
-
*
|
|
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);
|
|
2070
2085
|
* });
|
|
2071
2086
|
* ```
|
|
2087
|
+
* @since v21.2.0, v20.11.0
|
|
2072
2088
|
*/
|
|
2073
|
-
setTime(
|
|
2089
|
+
setTime(milliseconds: number): void;
|
|
2074
2090
|
/**
|
|
2075
2091
|
* This function restores the default behavior of all mocks that were previously
|
|
2076
2092
|
* created by this `MockTimers` instance and disassociates the mocks
|
|
@@ -2257,84 +2273,3 @@ declare module "node:test" {
|
|
|
2257
2273
|
}[keyof T];
|
|
2258
2274
|
export = test;
|
|
2259
2275
|
}
|
|
2260
|
-
|
|
2261
|
-
/**
|
|
2262
|
-
* The `node:test/reporters` module exposes the builtin-reporters for `node:test`.
|
|
2263
|
-
* To access it:
|
|
2264
|
-
*
|
|
2265
|
-
* ```js
|
|
2266
|
-
* import test from 'node:test/reporters';
|
|
2267
|
-
* ```
|
|
2268
|
-
*
|
|
2269
|
-
* This module is only available under the `node:` scheme. The following will not
|
|
2270
|
-
* work:
|
|
2271
|
-
*
|
|
2272
|
-
* ```js
|
|
2273
|
-
* import test from 'node:test/reporters';
|
|
2274
|
-
* ```
|
|
2275
|
-
* @since v19.9.0
|
|
2276
|
-
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/test/reporters.js)
|
|
2277
|
-
*/
|
|
2278
|
-
declare module "node:test/reporters" {
|
|
2279
|
-
import { Transform, TransformOptions } from "node:stream";
|
|
2280
|
-
import { EventData } from "node:test";
|
|
2281
|
-
|
|
2282
|
-
type TestEvent =
|
|
2283
|
-
| { type: "test:coverage"; data: EventData.TestCoverage }
|
|
2284
|
-
| { type: "test:complete"; data: EventData.TestComplete }
|
|
2285
|
-
| { type: "test:dequeue"; data: EventData.TestDequeue }
|
|
2286
|
-
| { type: "test:diagnostic"; data: EventData.TestDiagnostic }
|
|
2287
|
-
| { type: "test:enqueue"; data: EventData.TestEnqueue }
|
|
2288
|
-
| { type: "test:fail"; data: EventData.TestFail }
|
|
2289
|
-
| { type: "test:pass"; data: EventData.TestPass }
|
|
2290
|
-
| { type: "test:plan"; data: EventData.TestPlan }
|
|
2291
|
-
| { type: "test:start"; data: EventData.TestStart }
|
|
2292
|
-
| { type: "test:stderr"; data: EventData.TestStderr }
|
|
2293
|
-
| { type: "test:stdout"; data: EventData.TestStdout }
|
|
2294
|
-
| { type: "test:summary"; data: EventData.TestSummary }
|
|
2295
|
-
| { type: "test:watch:drained"; data: undefined }
|
|
2296
|
-
| { type: "test:watch:restarted"; data: undefined };
|
|
2297
|
-
type TestEventGenerator = AsyncGenerator<TestEvent, void>;
|
|
2298
|
-
|
|
2299
|
-
interface ReporterConstructorWrapper<T extends new(...args: any[]) => Transform> {
|
|
2300
|
-
new(...args: ConstructorParameters<T>): InstanceType<T>;
|
|
2301
|
-
(...args: ConstructorParameters<T>): InstanceType<T>;
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
/**
|
|
2305
|
-
* The `dot` reporter outputs the test results in a compact format,
|
|
2306
|
-
* where each passing test is represented by a `.`,
|
|
2307
|
-
* and each failing test is represented by a `X`.
|
|
2308
|
-
* @since v20.0.0
|
|
2309
|
-
*/
|
|
2310
|
-
function dot(source: TestEventGenerator): AsyncGenerator<"\n" | "." | "X", void>;
|
|
2311
|
-
/**
|
|
2312
|
-
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
|
|
2313
|
-
* @since v20.0.0
|
|
2314
|
-
*/
|
|
2315
|
-
function tap(source: TestEventGenerator): AsyncGenerator<string, void>;
|
|
2316
|
-
class SpecReporter extends Transform {
|
|
2317
|
-
constructor();
|
|
2318
|
-
}
|
|
2319
|
-
/**
|
|
2320
|
-
* The `spec` reporter outputs the test results in a human-readable format.
|
|
2321
|
-
* @since v20.0.0
|
|
2322
|
-
*/
|
|
2323
|
-
const spec: ReporterConstructorWrapper<typeof SpecReporter>;
|
|
2324
|
-
/**
|
|
2325
|
-
* The `junit` reporter outputs test results in a jUnit XML format.
|
|
2326
|
-
* @since v21.0.0
|
|
2327
|
-
*/
|
|
2328
|
-
function junit(source: TestEventGenerator): AsyncGenerator<string, void>;
|
|
2329
|
-
class LcovReporter extends Transform {
|
|
2330
|
-
constructor(opts?: Omit<TransformOptions, "writableObjectMode">);
|
|
2331
|
-
}
|
|
2332
|
-
/**
|
|
2333
|
-
* The `lcov` reporter outputs test coverage when used with the
|
|
2334
|
-
* [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--experimental-test-coverage) flag.
|
|
2335
|
-
* @since v22.0.0
|
|
2336
|
-
*/
|
|
2337
|
-
const lcov: ReporterConstructorWrapper<typeof LcovReporter>;
|
|
2338
|
-
|
|
2339
|
-
export { dot, junit, lcov, spec, tap, TestEvent };
|
|
2340
|
-
}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* } from 'node:timers/promises';
|
|
12
12
|
* ```
|
|
13
13
|
* @since v15.0.0
|
|
14
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
14
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/timers/promises.js)
|
|
15
15
|
*/
|
|
16
|
-
declare module "timers/promises" {
|
|
16
|
+
declare module "node:timers/promises" {
|
|
17
17
|
import { TimerOptions } from "node:timers";
|
|
18
18
|
/**
|
|
19
19
|
* ```js
|
|
@@ -103,6 +103,6 @@ declare module "timers/promises" {
|
|
|
103
103
|
}
|
|
104
104
|
const scheduler: Scheduler;
|
|
105
105
|
}
|
|
106
|
-
declare module "
|
|
107
|
-
export * from "timers/promises";
|
|
106
|
+
declare module "timers/promises" {
|
|
107
|
+
export * from "node:timers/promises";
|
|
108
108
|
}
|