@idlebox/stripe-node-types 24.0.14 → 24.0.15
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.
- package/README.md +1 -1
- package/assert/strict.d.ts +98 -1
- package/assert.d.ts +147 -248
- package/async_hooks.d.ts +5 -5
- package/buffer.buffer.d.ts +9 -6
- package/buffer.d.ts +49 -169
- package/child_process.d.ts +102 -223
- package/cluster.d.ts +236 -329
- package/console.d.ts +45 -346
- package/constants.d.ts +0 -1
- package/crypto.d.ts +698 -1149
- package/dgram.d.ts +15 -50
- package/diagnostics_channel.d.ts +1 -3
- package/dns.d.ts +135 -131
- package/domain.d.ts +10 -14
- package/events.d.ts +846 -722
- package/fs/promises.d.ts +102 -53
- package/fs.d.ts +714 -484
- package/globals.d.ts +130 -347
- package/globals.typedarray.d.ts +79 -0
- package/http.d.ts +343 -246
- package/http2.d.ts +563 -711
- package/https.d.ts +70 -216
- package/index.d.ts +24 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +167 -3938
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +45 -95
- package/net.d.ts +87 -186
- package/os.d.ts +17 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +117 -122
- package/perf_hooks.d.ts +295 -644
- package/process.d.ts +177 -138
- package/punycode.d.ts +2 -2
- package/querystring.d.ts +1 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +1 -1
- package/readline.d.ts +65 -118
- package/repl.d.ts +83 -96
- package/sea.d.ts +10 -1
- package/sqlite.d.ts +262 -13
- package/stream/consumers.d.ts +7 -7
- package/stream/promises.d.ts +133 -12
- package/stream/web.d.ts +173 -495
- package/stream.d.ts +593 -490
- package/string_decoder.d.ts +3 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +223 -199
- package/timers/promises.d.ts +1 -1
- package/timers.d.ts +1 -129
- package/tls.d.ts +148 -163
- package/trace_events.d.ts +6 -6
- package/ts5.6/buffer.buffer.d.ts +10 -8
- package/ts5.6/globals.typedarray.d.ts +16 -0
- package/ts5.6/index.d.ts +24 -3
- package/ts5.7/index.d.ts +24 -3
- package/tty.d.ts +55 -13
- package/url.d.ts +92 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +143 -792
- package/v8.d.ts +67 -7
- package/vm.d.ts +252 -108
- package/wasi.d.ts +23 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/{ts5.1/compatibility/disposable.d.ts → web-globals/console.d.ts} +6 -9
- package/web-globals/crypto.d.ts +55 -0
- package/web-globals/domexception.d.ts +84 -0
- package/web-globals/encoding.d.ts +27 -0
- package/{dom-events.d.ts → web-globals/events.d.ts} +57 -50
- package/web-globals/fetch.d.ts +70 -0
- package/web-globals/importmeta.d.ts +29 -0
- package/web-globals/messaging.d.ts +39 -0
- package/web-globals/navigator.d.ts +41 -0
- package/web-globals/performance.d.ts +61 -0
- package/web-globals/storage.d.ts +40 -0
- package/web-globals/streams.d.ts +131 -0
- package/web-globals/timers.d.ts +60 -0
- package/web-globals/url.d.ts +40 -0
- package/worker_threads.d.ts +291 -349
- package/zlib.d.ts +44 -94
- package/ts5.1/index.d.ts +0 -115
package/test.d.ts
CHANGED
|
@@ -91,29 +91,13 @@
|
|
|
91
91
|
*
|
|
92
92
|
* If any tests fail, the process exit code is set to `1`.
|
|
93
93
|
* @since v18.0.0, v16.17.0
|
|
94
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The `node:test/reporters` module exposes the builtin-reporters for `node:test`.
|
|
99
|
-
* To access it:
|
|
100
|
-
*
|
|
101
|
-
* ```js
|
|
102
|
-
* import test from 'node:test/reporters';
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* This module is only available under the `node:` scheme. The following will not
|
|
106
|
-
* work:
|
|
107
|
-
*
|
|
108
|
-
* ```js
|
|
109
|
-
* import test from 'node:test/reporters';
|
|
110
|
-
* ```
|
|
111
|
-
* @since v19.9.0
|
|
112
|
-
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/test/reporters.js)
|
|
94
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/test.js)
|
|
113
95
|
*/
|
|
114
96
|
|
|
115
97
|
declare module "node:test" {
|
|
116
|
-
import {
|
|
98
|
+
import { AssertMethodNames } from 'node:assert';
|
|
99
|
+
import { Readable, ReadableEventMap } from 'node:stream';
|
|
100
|
+
import { TestEvent } from 'node:test/reporters';
|
|
117
101
|
import TestFn = test.TestFn;
|
|
118
102
|
import TestOptions = test.TestOptions;
|
|
119
103
|
/**
|
|
@@ -276,14 +260,14 @@ declare module "node:test" {
|
|
|
276
260
|
/**
|
|
277
261
|
* Specifies the current working directory to be used by the test runner.
|
|
278
262
|
* Serves as the base path for resolving files according to the
|
|
279
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
263
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
|
|
280
264
|
* @since v23.0.0
|
|
281
265
|
* @default process.cwd()
|
|
282
266
|
*/
|
|
283
267
|
cwd?: string | undefined;
|
|
284
268
|
/**
|
|
285
269
|
* An array containing the list of files to run. If omitted, files are run according to the
|
|
286
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
270
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
|
|
287
271
|
*/
|
|
288
272
|
files?: readonly string[] | undefined;
|
|
289
273
|
/**
|
|
@@ -296,7 +280,7 @@ declare module "node:test" {
|
|
|
296
280
|
/**
|
|
297
281
|
* An array containing the list of glob patterns to match test files.
|
|
298
282
|
* This option cannot be used together with `files`. If omitted, files are run according to the
|
|
299
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
283
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
|
|
300
284
|
* @since v22.6.0
|
|
301
285
|
*/
|
|
302
286
|
globPatterns?: readonly string[] | undefined;
|
|
@@ -377,7 +361,14 @@ declare module "node:test" {
|
|
|
377
361
|
*/
|
|
378
362
|
shard?: TestShard | undefined;
|
|
379
363
|
/**
|
|
380
|
-
*
|
|
364
|
+
* A file path where the test runner will
|
|
365
|
+
* store the state of the tests to allow rerunning only the failed tests on a next run.
|
|
366
|
+
* @since v24.7.0
|
|
367
|
+
* @default undefined
|
|
368
|
+
*/
|
|
369
|
+
rerunFailuresFilePath?: string | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* enable [code coverage](https://nodejs.org/docs/latest-v25.x/api/test.html#collecting-code-coverage) collection.
|
|
381
372
|
* @since v22.10.0
|
|
382
373
|
* @default false
|
|
383
374
|
*/
|
|
@@ -424,6 +415,23 @@ declare module "node:test" {
|
|
|
424
415
|
*/
|
|
425
416
|
functionCoverage?: number | undefined;
|
|
426
417
|
}
|
|
418
|
+
interface TestsStreamEventMap extends ReadableEventMap {
|
|
419
|
+
"data": [data: TestEvent];
|
|
420
|
+
"test:coverage": [data: EventData.TestCoverage];
|
|
421
|
+
"test:complete": [data: EventData.TestComplete];
|
|
422
|
+
"test:dequeue": [data: EventData.TestDequeue];
|
|
423
|
+
"test:diagnostic": [data: EventData.TestDiagnostic];
|
|
424
|
+
"test:enqueue": [data: EventData.TestEnqueue];
|
|
425
|
+
"test:fail": [data: EventData.TestFail];
|
|
426
|
+
"test:pass": [data: EventData.TestPass];
|
|
427
|
+
"test:plan": [data: EventData.TestPlan];
|
|
428
|
+
"test:start": [data: EventData.TestStart];
|
|
429
|
+
"test:stderr": [data: EventData.TestStderr];
|
|
430
|
+
"test:stdout": [data: EventData.TestStdout];
|
|
431
|
+
"test:summary": [data: EventData.TestSummary];
|
|
432
|
+
"test:watch:drained": [];
|
|
433
|
+
"test:watch:restarted": [];
|
|
434
|
+
}
|
|
427
435
|
/**
|
|
428
436
|
* A successful call to `run()` will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.
|
|
429
437
|
*
|
|
@@ -431,90 +439,59 @@ declare module "node:test" {
|
|
|
431
439
|
* @since v18.9.0, v16.19.0
|
|
432
440
|
*/
|
|
433
441
|
interface TestsStream extends Readable {
|
|
434
|
-
|
|
435
|
-
addListener
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
addListener(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
once(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
488
|
-
once(event: "test:watch:drained", listener: () => void): this;
|
|
489
|
-
once(event: string, listener: (...args: any[]) => void): this;
|
|
490
|
-
prependListener(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
491
|
-
prependListener(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
492
|
-
prependListener(event: "test:dequeue", listener: (data: EventData.TestDequeue) => void): this;
|
|
493
|
-
prependListener(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
494
|
-
prependListener(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
495
|
-
prependListener(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
496
|
-
prependListener(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
497
|
-
prependListener(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
498
|
-
prependListener(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
499
|
-
prependListener(event: "test:stderr", listener: (data: EventData.TestStderr) => void): this;
|
|
500
|
-
prependListener(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
501
|
-
prependListener(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
502
|
-
prependListener(event: "test:watch:drained", listener: () => void): this;
|
|
503
|
-
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
504
|
-
prependOnceListener(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
505
|
-
prependOnceListener(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
506
|
-
prependOnceListener(event: "test:dequeue", listener: (data: EventData.TestDequeue) => void): this;
|
|
507
|
-
prependOnceListener(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
508
|
-
prependOnceListener(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
509
|
-
prependOnceListener(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
510
|
-
prependOnceListener(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
511
|
-
prependOnceListener(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
512
|
-
prependOnceListener(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
513
|
-
prependOnceListener(event: "test:stderr", listener: (data: EventData.TestStderr) => void): this;
|
|
514
|
-
prependOnceListener(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
515
|
-
prependOnceListener(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
516
|
-
prependOnceListener(event: "test:watch:drained", listener: () => void): this;
|
|
517
|
-
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
442
|
+
// #region InternalEventEmitter
|
|
443
|
+
addListener<E extends keyof TestsStreamEventMap>(
|
|
444
|
+
eventName: E,
|
|
445
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
446
|
+
): this;
|
|
447
|
+
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
448
|
+
emit<E extends keyof TestsStreamEventMap>(eventName: E, ...args: TestsStreamEventMap[E]): boolean;
|
|
449
|
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
450
|
+
listenerCount<E extends keyof TestsStreamEventMap>(
|
|
451
|
+
eventName: E,
|
|
452
|
+
listener?: (...args: TestsStreamEventMap[E]) => void,
|
|
453
|
+
): number;
|
|
454
|
+
listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
|
|
455
|
+
listeners<E extends keyof TestsStreamEventMap>(eventName: E): ((...args: TestsStreamEventMap[E]) => void)[];
|
|
456
|
+
listeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
457
|
+
off<E extends keyof TestsStreamEventMap>(
|
|
458
|
+
eventName: E,
|
|
459
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
460
|
+
): this;
|
|
461
|
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
462
|
+
on<E extends keyof TestsStreamEventMap>(
|
|
463
|
+
eventName: E,
|
|
464
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
465
|
+
): this;
|
|
466
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
467
|
+
once<E extends keyof TestsStreamEventMap>(
|
|
468
|
+
eventName: E,
|
|
469
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
470
|
+
): this;
|
|
471
|
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
472
|
+
prependListener<E extends keyof TestsStreamEventMap>(
|
|
473
|
+
eventName: E,
|
|
474
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
475
|
+
): this;
|
|
476
|
+
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
477
|
+
prependOnceListener<E extends keyof TestsStreamEventMap>(
|
|
478
|
+
eventName: E,
|
|
479
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
480
|
+
): this;
|
|
481
|
+
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
482
|
+
rawListeners<E extends keyof TestsStreamEventMap>(
|
|
483
|
+
eventName: E,
|
|
484
|
+
): ((...args: TestsStreamEventMap[E]) => void)[];
|
|
485
|
+
rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
486
|
+
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
|
487
|
+
removeAllListeners<E extends keyof TestsStreamEventMap>(eventName?: E): this;
|
|
488
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
489
|
+
removeListener<E extends keyof TestsStreamEventMap>(
|
|
490
|
+
eventName: E,
|
|
491
|
+
listener: (...args: TestsStreamEventMap[E]) => void,
|
|
492
|
+
): this;
|
|
493
|
+
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
494
|
+
// #endregion
|
|
518
495
|
}
|
|
519
496
|
namespace EventData {
|
|
520
497
|
interface Error extends globalThis.Error {
|
|
@@ -544,6 +521,14 @@ declare module "node:test" {
|
|
|
544
521
|
* The nesting level of the test.
|
|
545
522
|
*/
|
|
546
523
|
nesting: number;
|
|
524
|
+
/**
|
|
525
|
+
* The severity level of the diagnostic message.
|
|
526
|
+
* Possible values are:
|
|
527
|
+
* * `'info'`: Informational messages.
|
|
528
|
+
* * `'warn'`: Warnings.
|
|
529
|
+
* * `'error'`: Errors.
|
|
530
|
+
*/
|
|
531
|
+
level: "info" | "warn" | "error";
|
|
547
532
|
}
|
|
548
533
|
interface TestCoverage {
|
|
549
534
|
/**
|
|
@@ -730,7 +715,7 @@ declare module "node:test" {
|
|
|
730
715
|
/**
|
|
731
716
|
* The type of the test, used to denote whether this is a suite.
|
|
732
717
|
*/
|
|
733
|
-
type?: "suite";
|
|
718
|
+
type?: "suite" | "test";
|
|
734
719
|
};
|
|
735
720
|
/**
|
|
736
721
|
* The test name.
|
|
@@ -800,7 +785,13 @@ declare module "node:test" {
|
|
|
800
785
|
* The type of the test, used to denote whether this is a suite.
|
|
801
786
|
* @since v20.0.0, v19.9.0, v18.17.0
|
|
802
787
|
*/
|
|
803
|
-
type?: "suite";
|
|
788
|
+
type?: "suite" | "test";
|
|
789
|
+
/**
|
|
790
|
+
* The attempt number of the test run,
|
|
791
|
+
* present only when using the `--test-rerun-failures` flag.
|
|
792
|
+
* @since v24.7.0
|
|
793
|
+
*/
|
|
794
|
+
attempt?: number;
|
|
804
795
|
};
|
|
805
796
|
/**
|
|
806
797
|
* The test name.
|
|
@@ -836,7 +827,19 @@ declare module "node:test" {
|
|
|
836
827
|
* The type of the test, used to denote whether this is a suite.
|
|
837
828
|
* @since 20.0.0, 19.9.0, 18.17.0
|
|
838
829
|
*/
|
|
839
|
-
type?: "suite";
|
|
830
|
+
type?: "suite" | "test";
|
|
831
|
+
/**
|
|
832
|
+
* The attempt number of the test run,
|
|
833
|
+
* present only when using the `--test-rerun-failures` flag.
|
|
834
|
+
* @since v24.7.0
|
|
835
|
+
*/
|
|
836
|
+
attempt?: number;
|
|
837
|
+
/**
|
|
838
|
+
* The attempt number the test passed on,
|
|
839
|
+
* present only when using the `--test-rerun-failures` flag.
|
|
840
|
+
* @since v24.7.0
|
|
841
|
+
*/
|
|
842
|
+
passed_on_attempt?: number;
|
|
840
843
|
};
|
|
841
844
|
/**
|
|
842
845
|
* The test name.
|
|
@@ -981,6 +984,7 @@ declare module "node:test" {
|
|
|
981
984
|
* @since v22.2.0, v20.15.0
|
|
982
985
|
*/
|
|
983
986
|
readonly assert: TestContextAssert;
|
|
987
|
+
readonly attempt: number;
|
|
984
988
|
/**
|
|
985
989
|
* This function is used to create a hook running before subtest of the current test.
|
|
986
990
|
* @param fn The hook function. The first argument to this function is a `TestContext` object.
|
|
@@ -1191,29 +1195,7 @@ declare module "node:test" {
|
|
|
1191
1195
|
*/
|
|
1192
1196
|
readonly mock: MockTracker;
|
|
1193
1197
|
}
|
|
1194
|
-
interface TestContextAssert extends
|
|
1195
|
-
Pick<
|
|
1196
|
-
typeof import('node:assert'),
|
|
1197
|
-
| "deepEqual"
|
|
1198
|
-
| "deepStrictEqual"
|
|
1199
|
-
| "doesNotMatch"
|
|
1200
|
-
| "doesNotReject"
|
|
1201
|
-
| "doesNotThrow"
|
|
1202
|
-
| "equal"
|
|
1203
|
-
| "fail"
|
|
1204
|
-
| "ifError"
|
|
1205
|
-
| "match"
|
|
1206
|
-
| "notDeepEqual"
|
|
1207
|
-
| "notDeepStrictEqual"
|
|
1208
|
-
| "notEqual"
|
|
1209
|
-
| "notStrictEqual"
|
|
1210
|
-
| "ok"
|
|
1211
|
-
| "partialDeepStrictEqual"
|
|
1212
|
-
| "rejects"
|
|
1213
|
-
| "strictEqual"
|
|
1214
|
-
| "throws"
|
|
1215
|
-
>
|
|
1216
|
-
{
|
|
1198
|
+
interface TestContextAssert extends Pick<typeof import('node:assert'), AssertMethodNames> {
|
|
1217
1199
|
/**
|
|
1218
1200
|
* This function serializes `value` and writes it to the file specified by `path`.
|
|
1219
1201
|
*
|
|
@@ -1233,7 +1215,7 @@ declare module "node:test" {
|
|
|
1233
1215
|
* highlighting.
|
|
1234
1216
|
* @since v22.14.0
|
|
1235
1217
|
* @param value A value to serialize to a string. If Node.js was started with
|
|
1236
|
-
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-
|
|
1218
|
+
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--test-update-snapshots)
|
|
1237
1219
|
* flag, the serialized value is written to
|
|
1238
1220
|
* `path`. Otherwise, the serialized value is compared to the contents of the
|
|
1239
1221
|
* existing snapshot file.
|
|
@@ -1256,7 +1238,7 @@ declare module "node:test" {
|
|
|
1256
1238
|
* ```
|
|
1257
1239
|
* @since v22.3.0
|
|
1258
1240
|
* @param value A value to serialize to a string. If Node.js was started with
|
|
1259
|
-
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-
|
|
1241
|
+
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--test-update-snapshots)
|
|
1260
1242
|
* flag, the serialized value is written to
|
|
1261
1243
|
* the snapshot file. Otherwise, the serialized value is compared to the
|
|
1262
1244
|
* corresponding value in the existing snapshot file.
|
|
@@ -1687,7 +1669,7 @@ declare module "node:test" {
|
|
|
1687
1669
|
* This function is used to mock the exports of ECMAScript modules, CommonJS modules, JSON modules, and
|
|
1688
1670
|
* Node.js builtin modules. Any references to the original module prior to mocking are not impacted. In
|
|
1689
1671
|
* order to enable module mocking, Node.js must be started with the
|
|
1690
|
-
* [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-
|
|
1672
|
+
* [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--experimental-test-module-mocks)
|
|
1691
1673
|
* command-line flag.
|
|
1692
1674
|
*
|
|
1693
1675
|
* The following example demonstrates how a mock is created for a module.
|
|
@@ -1727,6 +1709,46 @@ declare module "node:test" {
|
|
|
1727
1709
|
* @param options Optional configuration options for the mock module.
|
|
1728
1710
|
*/
|
|
1729
1711
|
module(specifier: string, options?: MockModuleOptions): MockModuleContext;
|
|
1712
|
+
/**
|
|
1713
|
+
* Creates a mock for a property value on an object. This allows you to track and control access to a specific property,
|
|
1714
|
+
* including how many times it is read (getter) or written (setter), and to restore the original value after mocking.
|
|
1715
|
+
*
|
|
1716
|
+
* ```js
|
|
1717
|
+
* test('mocks a property value', (t) => {
|
|
1718
|
+
* const obj = { foo: 42 };
|
|
1719
|
+
* const prop = t.mock.property(obj, 'foo', 100);
|
|
1720
|
+
*
|
|
1721
|
+
* assert.strictEqual(obj.foo, 100);
|
|
1722
|
+
* assert.strictEqual(prop.mock.accessCount(), 1);
|
|
1723
|
+
* assert.strictEqual(prop.mock.accesses[0].type, 'get');
|
|
1724
|
+
* assert.strictEqual(prop.mock.accesses[0].value, 100);
|
|
1725
|
+
*
|
|
1726
|
+
* obj.foo = 200;
|
|
1727
|
+
* assert.strictEqual(prop.mock.accessCount(), 2);
|
|
1728
|
+
* assert.strictEqual(prop.mock.accesses[1].type, 'set');
|
|
1729
|
+
* assert.strictEqual(prop.mock.accesses[1].value, 200);
|
|
1730
|
+
*
|
|
1731
|
+
* prop.mock.restore();
|
|
1732
|
+
* assert.strictEqual(obj.foo, 42);
|
|
1733
|
+
* });
|
|
1734
|
+
* ```
|
|
1735
|
+
* @since v24.3.0
|
|
1736
|
+
* @param object The object whose value is being mocked.
|
|
1737
|
+
* @param propertyName The identifier of the property on `object` to mock.
|
|
1738
|
+
* @param value An optional value used as the mock value
|
|
1739
|
+
* for `object[propertyName]`. **Default:** The original property value.
|
|
1740
|
+
* @returns A proxy to the mocked object. The mocked object contains a
|
|
1741
|
+
* special `mock` property, which is an instance of [`MockPropertyContext`][], and
|
|
1742
|
+
* can be used for inspecting and changing the behavior of the mocked property.
|
|
1743
|
+
*/
|
|
1744
|
+
property<
|
|
1745
|
+
MockedObject extends object,
|
|
1746
|
+
PropertyName extends keyof MockedObject,
|
|
1747
|
+
>(
|
|
1748
|
+
object: MockedObject,
|
|
1749
|
+
property: PropertyName,
|
|
1750
|
+
value?: MockedObject[PropertyName],
|
|
1751
|
+
): MockedObject & { mock: MockPropertyContext<MockedObject[PropertyName]> };
|
|
1730
1752
|
/**
|
|
1731
1753
|
* This function restores the default behavior of all mocks that were previously
|
|
1732
1754
|
* created by this `MockTracker` and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used, but the `MockTracker` instance can no longer be
|
|
@@ -1896,6 +1918,70 @@ declare module "node:test" {
|
|
|
1896
1918
|
*/
|
|
1897
1919
|
restore(): void;
|
|
1898
1920
|
}
|
|
1921
|
+
/**
|
|
1922
|
+
* @since v24.3.0
|
|
1923
|
+
*/
|
|
1924
|
+
class MockPropertyContext<PropertyType = any> {
|
|
1925
|
+
/**
|
|
1926
|
+
* A getter that returns a copy of the internal array used to track accesses (get/set) to
|
|
1927
|
+
* the mocked property. Each entry in the array is an object with the following properties:
|
|
1928
|
+
*/
|
|
1929
|
+
readonly accesses: Array<{
|
|
1930
|
+
type: "get" | "set";
|
|
1931
|
+
value: PropertyType;
|
|
1932
|
+
stack: Error;
|
|
1933
|
+
}>;
|
|
1934
|
+
/**
|
|
1935
|
+
* This function returns the number of times that the property was accessed.
|
|
1936
|
+
* This function is more efficient than checking `ctx.accesses.length` because
|
|
1937
|
+
* `ctx.accesses` is a getter that creates a copy of the internal access tracking array.
|
|
1938
|
+
* @returns The number of times that the property was accessed (read or written).
|
|
1939
|
+
*/
|
|
1940
|
+
accessCount(): number;
|
|
1941
|
+
/**
|
|
1942
|
+
* This function is used to change the value returned by the mocked property getter.
|
|
1943
|
+
* @param value The new value to be set as the mocked property value.
|
|
1944
|
+
*/
|
|
1945
|
+
mockImplementation(value: PropertyType): void;
|
|
1946
|
+
/**
|
|
1947
|
+
* This function is used to change the behavior of an existing mock for a single
|
|
1948
|
+
* invocation. Once invocation `onAccess` has occurred, the mock will revert to
|
|
1949
|
+
* whatever behavior it would have used had `mockImplementationOnce()` not been
|
|
1950
|
+
* called.
|
|
1951
|
+
*
|
|
1952
|
+
* The following example creates a mock function using `t.mock.property()`, calls the
|
|
1953
|
+
* mock property, changes the mock implementation to a different value for the
|
|
1954
|
+
* next invocation, and then resumes its previous behavior.
|
|
1955
|
+
*
|
|
1956
|
+
* ```js
|
|
1957
|
+
* test('changes a mock behavior once', (t) => {
|
|
1958
|
+
* const obj = { foo: 1 };
|
|
1959
|
+
*
|
|
1960
|
+
* const prop = t.mock.property(obj, 'foo', 5);
|
|
1961
|
+
*
|
|
1962
|
+
* assert.strictEqual(obj.foo, 5);
|
|
1963
|
+
* prop.mock.mockImplementationOnce(25);
|
|
1964
|
+
* assert.strictEqual(obj.foo, 25);
|
|
1965
|
+
* assert.strictEqual(obj.foo, 5);
|
|
1966
|
+
* });
|
|
1967
|
+
* ```
|
|
1968
|
+
* @param value The value to be used as the mock's
|
|
1969
|
+
* implementation for the invocation number specified by `onAccess`.
|
|
1970
|
+
* @param onAccess The invocation number that will use `value`. If
|
|
1971
|
+
* the specified invocation has already occurred then an exception is thrown.
|
|
1972
|
+
* **Default:** The number of the next invocation.
|
|
1973
|
+
*/
|
|
1974
|
+
mockImplementationOnce(value: PropertyType, onAccess?: number): void;
|
|
1975
|
+
/**
|
|
1976
|
+
* Resets the access history of the mocked property.
|
|
1977
|
+
*/
|
|
1978
|
+
resetAccesses(): void;
|
|
1979
|
+
/**
|
|
1980
|
+
* Resets the implementation of the mock property to its original behavior. The
|
|
1981
|
+
* mock can still be used after calling this function.
|
|
1982
|
+
*/
|
|
1983
|
+
restore(): void;
|
|
1984
|
+
}
|
|
1899
1985
|
interface MockTimersOptions {
|
|
1900
1986
|
apis: ReadonlyArray<"setInterval" | "setTimeout" | "setImmediate" | "Date">;
|
|
1901
1987
|
now?: number | Date | undefined;
|
|
@@ -2167,65 +2253,3 @@ declare module "node:test" {
|
|
|
2167
2253
|
}[keyof T];
|
|
2168
2254
|
export = test;
|
|
2169
2255
|
}
|
|
2170
|
-
declare module "node:test/reporters" {
|
|
2171
|
-
import { Transform, TransformOptions } from 'node:stream';
|
|
2172
|
-
import { EventData } from 'node:test';
|
|
2173
|
-
|
|
2174
|
-
type TestEvent =
|
|
2175
|
-
| { type: "test:coverage"; data: EventData.TestCoverage }
|
|
2176
|
-
| { type: "test:complete"; data: EventData.TestComplete }
|
|
2177
|
-
| { type: "test:dequeue"; data: EventData.TestDequeue }
|
|
2178
|
-
| { type: "test:diagnostic"; data: EventData.TestDiagnostic }
|
|
2179
|
-
| { type: "test:enqueue"; data: EventData.TestEnqueue }
|
|
2180
|
-
| { type: "test:fail"; data: EventData.TestFail }
|
|
2181
|
-
| { type: "test:pass"; data: EventData.TestPass }
|
|
2182
|
-
| { type: "test:plan"; data: EventData.TestPlan }
|
|
2183
|
-
| { type: "test:start"; data: EventData.TestStart }
|
|
2184
|
-
| { type: "test:stderr"; data: EventData.TestStderr }
|
|
2185
|
-
| { type: "test:stdout"; data: EventData.TestStdout }
|
|
2186
|
-
| { type: "test:summary"; data: EventData.TestSummary }
|
|
2187
|
-
| { type: "test:watch:drained"; data: undefined };
|
|
2188
|
-
type TestEventGenerator = AsyncGenerator<TestEvent, void>;
|
|
2189
|
-
|
|
2190
|
-
interface ReporterConstructorWrapper<T extends new(...args: any[]) => Transform> {
|
|
2191
|
-
new(...args: ConstructorParameters<T>): InstanceType<T>;
|
|
2192
|
-
(...args: ConstructorParameters<T>): InstanceType<T>;
|
|
2193
|
-
}
|
|
2194
|
-
|
|
2195
|
-
/**
|
|
2196
|
-
* The `dot` reporter outputs the test results in a compact format,
|
|
2197
|
-
* where each passing test is represented by a `.`,
|
|
2198
|
-
* and each failing test is represented by a `X`.
|
|
2199
|
-
* @since v20.0.0
|
|
2200
|
-
*/
|
|
2201
|
-
function dot(source: TestEventGenerator): AsyncGenerator<"\n" | "." | "X", void>;
|
|
2202
|
-
/**
|
|
2203
|
-
* The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
|
|
2204
|
-
* @since v20.0.0
|
|
2205
|
-
*/
|
|
2206
|
-
function tap(source: TestEventGenerator): AsyncGenerator<string, void>;
|
|
2207
|
-
class SpecReporter extends Transform {
|
|
2208
|
-
constructor();
|
|
2209
|
-
}
|
|
2210
|
-
/**
|
|
2211
|
-
* The `spec` reporter outputs the test results in a human-readable format.
|
|
2212
|
-
* @since v20.0.0
|
|
2213
|
-
*/
|
|
2214
|
-
const spec: ReporterConstructorWrapper<typeof SpecReporter>;
|
|
2215
|
-
/**
|
|
2216
|
-
* The `junit` reporter outputs test results in a jUnit XML format.
|
|
2217
|
-
* @since v21.0.0
|
|
2218
|
-
*/
|
|
2219
|
-
function junit(source: TestEventGenerator): AsyncGenerator<string, void>;
|
|
2220
|
-
class LcovReporter extends Transform {
|
|
2221
|
-
constructor(opts?: Omit<TransformOptions, "writableObjectMode">);
|
|
2222
|
-
}
|
|
2223
|
-
/**
|
|
2224
|
-
* The `lcov` reporter outputs test coverage when used with the
|
|
2225
|
-
* [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--experimental-test-coverage) flag.
|
|
2226
|
-
* @since v22.0.0
|
|
2227
|
-
*/
|
|
2228
|
-
const lcov: ReporterConstructorWrapper<typeof LcovReporter>;
|
|
2229
|
-
|
|
2230
|
-
export { dot, junit, lcov, spec, tap, TestEvent };
|
|
2231
|
-
}
|
package/timers/promises.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* } from 'node:timers/promises';
|
|
27
27
|
* ```
|
|
28
28
|
* @since v15.0.0
|
|
29
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
29
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/timers/promises.js)
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
declare module "node:timers/promises" {
|