@types/node 24.13.6 → 24.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.
- {node v24.13 → node v24.19}/README.md +1 -1
- {node v24.13 → node v24.19}/async_hooks.d.ts +18 -22
- {node v24.13 → node v24.19}/buffer.buffer.d.ts +10 -5
- {node v24.13 → node v24.19}/buffer.d.ts +7 -0
- {node v24.13 → node v24.19}/child_process.d.ts +5 -1
- {node v24.13 → node v24.19}/crypto.d.ts +114 -47
- {node v24.13 → node v24.19}/dgram.d.ts +119 -4
- {node v24.13 → node v24.19}/dns/promises.d.ts +5 -5
- {node v24.13 → node v24.19}/dns.d.ts +6 -6
- {node v24.13 → node v24.19}/events.d.ts +13 -22
- {node v24.13 → node v24.19}/fs/promises.d.ts +79 -66
- {node v24.13 → node v24.19}/fs.d.ts +153 -90
- {node v24.13 → node v24.19}/http.d.ts +94 -2
- {node v24.13 → node v24.19}/http2.d.ts +65 -18
- {node v24.13 → node v24.19}/inspector.d.ts +47 -1
- {node v24.13 → node v24.19}/inspector.generated.d.ts +167 -0
- {node v24.13 → node v24.19}/module.d.ts +1 -0
- {node v24.13 → node v24.19}/net.d.ts +139 -15
- {node v24.13 → node v24.19}/os.d.ts +30 -30
- {node v24.13 → node v24.19}/package.json +3 -3
- {node v24.13 → node v24.19}/perf_hooks.d.ts +31 -19
- {node v24.13 → node v24.19}/process.d.ts +42 -43
- {node v24.13 → node v24.19}/sqlite.d.ts +153 -11
- {node v24.13 → node v24.19}/stream/consumers.d.ts +7 -0
- {node v24.13 → node v24.19}/stream/web.d.ts +19 -0
- {node v24.13 → node v24.19}/stream.d.ts +2 -1
- {node v24.13 → node v24.19}/test.d.ts +320 -13
- {node v24.13 → node v24.19}/tls.d.ts +50 -15
- {node v24.13 → node v24.19}/ts5.6/buffer.buffer.d.ts +5 -0
- {node v24.13 → node v24.19}/tty.d.ts +4 -3
- {node v24.13 → node v24.19}/url.d.ts +27 -3
- {node v24.13 → node v24.19}/util.d.ts +42 -2
- {node v24.13 → node v24.19}/v8.d.ts +51 -23
- {node v24.13 → node v24.19}/vm.d.ts +52 -87
- {node v24.13 → node v24.19}/zlib.d.ts +17 -0
- {node v24.13 → node v24.19}/LICENSE +0 -0
- {node v24.13 → node v24.19}/assert/strict.d.ts +0 -0
- {node v24.13 → node v24.19}/assert.d.ts +0 -0
- {node v24.13 → node v24.19}/cluster.d.ts +0 -0
- {node v24.13 → node v24.19}/compatibility/iterators.d.ts +0 -0
- {node v24.13 → node v24.19}/console.d.ts +0 -0
- {node v24.13 → node v24.19}/constants.d.ts +0 -0
- {node v24.13 → node v24.19}/diagnostics_channel.d.ts +0 -0
- {node v24.13 → node v24.19}/domain.d.ts +0 -0
- {node v24.13 → node v24.19}/globals.d.ts +0 -0
- {node v24.13 → node v24.19}/globals.typedarray.d.ts +0 -0
- {node v24.13 → node v24.19}/https.d.ts +0 -0
- {node v24.13 → node v24.19}/index.d.ts +0 -0
- {node v24.13 → node v24.19}/path.d.ts +0 -0
- {node v24.13 → node v24.19}/punycode.d.ts +0 -0
- {node v24.13 → node v24.19}/querystring.d.ts +0 -0
- {node v24.13 → node v24.19}/readline/promises.d.ts +0 -0
- {node v24.13 → node v24.19}/readline.d.ts +0 -0
- {node v24.13 → node v24.19}/repl.d.ts +0 -0
- {node v24.13 → node v24.19}/sea.d.ts +0 -0
- {node v24.13 → node v24.19}/stream/promises.d.ts +0 -0
- {node v24.13 → node v24.19}/string_decoder.d.ts +0 -0
- {node v24.13 → node v24.19}/timers/promises.d.ts +0 -0
- {node v24.13 → node v24.19}/timers.d.ts +0 -0
- {node v24.13 → node v24.19}/trace_events.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.6/compatibility/float16array.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.6/globals.typedarray.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.6/index.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.7/compatibility/float16array.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.7/index.d.ts +0 -0
- {node v24.13 → node v24.19}/wasi.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/abortcontroller.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/crypto.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/domexception.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/events.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/fetch.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/navigator.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/storage.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/streams.d.ts +0 -0
- {node v24.13 → node v24.19}/worker_threads.d.ts +0 -0
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/test.js)
|
|
80
80
|
*/
|
|
81
81
|
declare module "node:test" {
|
|
82
|
-
import { AssertMethodNames } from "node:assert";
|
|
82
|
+
import { AssertMethodNames, AssertPredicate } from "node:assert";
|
|
83
83
|
import { Readable } from "node:stream";
|
|
84
84
|
import { URL } from "node:url";
|
|
85
85
|
import TestFn = test.TestFn;
|
|
@@ -190,6 +190,16 @@ declare module "node:test" {
|
|
|
190
190
|
function only(name?: string, fn?: SuiteFn): Promise<void>;
|
|
191
191
|
function only(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
192
192
|
function only(fn?: SuiteFn): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* This flips the pass/fail reporting for a specific test or suite: a flagged test
|
|
195
|
+
* case must throw in order to pass, and a flagged test case that does not throw
|
|
196
|
+
* fails.
|
|
197
|
+
* @since v24.15.0
|
|
198
|
+
*/
|
|
199
|
+
function expectFailure(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
200
|
+
function expectFailure(name?: string, fn?: SuiteFn): Promise<void>;
|
|
201
|
+
function expectFailure(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
202
|
+
function expectFailure(fn?: SuiteFn): Promise<void>;
|
|
193
203
|
}
|
|
194
204
|
/**
|
|
195
205
|
* Shorthand for skipping a test. This is the same as calling {@link test} with `options.skip` set to `true`.
|
|
@@ -215,6 +225,11 @@ declare module "node:test" {
|
|
|
215
225
|
function only(name?: string, fn?: TestFn): Promise<void>;
|
|
216
226
|
function only(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
217
227
|
function only(fn?: TestFn): Promise<void>;
|
|
228
|
+
// added in v25.5.0, undocumented
|
|
229
|
+
function expectFailure(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
230
|
+
function expectFailure(name?: string, fn?: TestFn): Promise<void>;
|
|
231
|
+
function expectFailure(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
232
|
+
function expectFailure(fn?: TestFn): Promise<void>;
|
|
218
233
|
/**
|
|
219
234
|
* The type of a function passed to {@link test}. The first argument to this function is a {@link TestContext} object.
|
|
220
235
|
* If the test uses callbacks, the callback function is passed as the second argument.
|
|
@@ -328,6 +343,15 @@ declare module "node:test" {
|
|
|
328
343
|
* @since v22.1.0
|
|
329
344
|
*/
|
|
330
345
|
testSkipPatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* A tag name, or an array of tag names,
|
|
348
|
+
* used to filter tests by their declared tags. Tests must contain every
|
|
349
|
+
* listed tag to run. Equivalent to passing `--experimental-test-tag-filter`
|
|
350
|
+
* on the command line. See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
351
|
+
* @default undefined
|
|
352
|
+
* @since v24.19.0
|
|
353
|
+
*/
|
|
354
|
+
testTagFilters?: string | readonly string[] | undefined;
|
|
331
355
|
/**
|
|
332
356
|
* The number of milliseconds after which the test execution will fail.
|
|
333
357
|
* If unspecified, subtests inherit this value from their parent.
|
|
@@ -344,6 +368,20 @@ declare module "node:test" {
|
|
|
344
368
|
* @default undefined
|
|
345
369
|
*/
|
|
346
370
|
shard?: TestShard | undefined;
|
|
371
|
+
/**
|
|
372
|
+
* Randomize execution order for test files and queued tests.
|
|
373
|
+
* This option is not supported with `watch: true`.
|
|
374
|
+
* @since v24.16.0
|
|
375
|
+
* @default false
|
|
376
|
+
*/
|
|
377
|
+
randomize?: boolean | undefined;
|
|
378
|
+
/**
|
|
379
|
+
* Seed used when randomizing execution order. If this
|
|
380
|
+
* option is set, runs can replay the same randomized order deterministically,
|
|
381
|
+
* and setting this option also enables randomization. The value must be an
|
|
382
|
+
* integer between `0` and `4294967295`.
|
|
383
|
+
*/
|
|
384
|
+
randomSeed?: number | undefined;
|
|
347
385
|
/**
|
|
348
386
|
* A file path where the test runner will
|
|
349
387
|
* store the state of the tests to allow rerunning only the failed tests on a next run.
|
|
@@ -398,6 +436,14 @@ declare module "node:test" {
|
|
|
398
436
|
* @default 0
|
|
399
437
|
*/
|
|
400
438
|
functionCoverage?: number | undefined;
|
|
439
|
+
/**
|
|
440
|
+
* Specify environment variables to be passed along to the test process.
|
|
441
|
+
* This option is not compatible with `isolation='none'`. These variables will override
|
|
442
|
+
* those from the main process, and are not merged with `process.env`.
|
|
443
|
+
* @since v24.14.0
|
|
444
|
+
* @default process.env
|
|
445
|
+
*/
|
|
446
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
401
447
|
}
|
|
402
448
|
/**
|
|
403
449
|
* A successful call to `run()` will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.
|
|
@@ -412,6 +458,7 @@ declare module "node:test" {
|
|
|
412
458
|
addListener(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
413
459
|
addListener(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
414
460
|
addListener(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
461
|
+
addListener(event: "test:interrupted", listener: (data: EventData.TestInterrupted) => void): this;
|
|
415
462
|
addListener(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
416
463
|
addListener(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
417
464
|
addListener(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
@@ -427,6 +474,7 @@ declare module "node:test" {
|
|
|
427
474
|
emit(event: "test:diagnostic", data: EventData.TestDiagnostic): boolean;
|
|
428
475
|
emit(event: "test:enqueue", data: EventData.TestEnqueue): boolean;
|
|
429
476
|
emit(event: "test:fail", data: EventData.TestFail): boolean;
|
|
477
|
+
emit(event: "test:interrupted", data: EventData.TestInterrupted): boolean;
|
|
430
478
|
emit(event: "test:pass", data: EventData.TestPass): boolean;
|
|
431
479
|
emit(event: "test:plan", data: EventData.TestPlan): boolean;
|
|
432
480
|
emit(event: "test:start", data: EventData.TestStart): boolean;
|
|
@@ -442,6 +490,7 @@ declare module "node:test" {
|
|
|
442
490
|
on(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
443
491
|
on(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
444
492
|
on(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
493
|
+
on(event: "test:interrupted", listener: (data: EventData.TestInterrupted) => void): this;
|
|
445
494
|
on(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
446
495
|
on(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
447
496
|
on(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
@@ -457,6 +506,7 @@ declare module "node:test" {
|
|
|
457
506
|
once(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
458
507
|
once(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
459
508
|
once(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
509
|
+
once(event: "test:interrupted", listener: (data: EventData.TestInterrupted) => void): this;
|
|
460
510
|
once(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
461
511
|
once(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
462
512
|
once(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
@@ -472,6 +522,7 @@ declare module "node:test" {
|
|
|
472
522
|
prependListener(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
473
523
|
prependListener(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
474
524
|
prependListener(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
525
|
+
prependListener(event: "test:interrupted", listener: (data: EventData.TestInterrupted) => void): this;
|
|
475
526
|
prependListener(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
476
527
|
prependListener(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
477
528
|
prependListener(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
@@ -487,6 +538,7 @@ declare module "node:test" {
|
|
|
487
538
|
prependOnceListener(event: "test:diagnostic", listener: (data: EventData.TestDiagnostic) => void): this;
|
|
488
539
|
prependOnceListener(event: "test:enqueue", listener: (data: EventData.TestEnqueue) => void): this;
|
|
489
540
|
prependOnceListener(event: "test:fail", listener: (data: EventData.TestFail) => void): this;
|
|
541
|
+
prependOnceListener(event: "test:interrupted", listener: (data: EventData.TestInterrupted) => void): this;
|
|
490
542
|
prependOnceListener(event: "test:pass", listener: (data: EventData.TestPass) => void): this;
|
|
491
543
|
prependOnceListener(event: "test:plan", listener: (data: EventData.TestPlan) => void): this;
|
|
492
544
|
prependOnceListener(event: "test:start", listener: (data: EventData.TestStart) => void): this;
|
|
@@ -729,6 +781,24 @@ declare module "node:test" {
|
|
|
729
781
|
* The nesting level of the test.
|
|
730
782
|
*/
|
|
731
783
|
nesting: number;
|
|
784
|
+
/**
|
|
785
|
+
* The `testId` of the enclosing test, or
|
|
786
|
+
* `undefined` for top-level tests. Lets custom reporters track lineage
|
|
787
|
+
* when concurrent siblings at the same nesting level interleave.
|
|
788
|
+
*/
|
|
789
|
+
parentId: number | undefined;
|
|
790
|
+
/**
|
|
791
|
+
* The flattened lowercased tags declared on the test
|
|
792
|
+
* and its ancestor suites, in declaration order. Empty for untagged tests.
|
|
793
|
+
* See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
794
|
+
*/
|
|
795
|
+
tags: string[];
|
|
796
|
+
/**
|
|
797
|
+
* A numeric identifier for this test instance, unique
|
|
798
|
+
* within the test file's process. Consistent across all events for the same
|
|
799
|
+
* test instance, enabling reliable correlation in custom reporters.
|
|
800
|
+
*/
|
|
801
|
+
testId: number;
|
|
732
802
|
/**
|
|
733
803
|
* The ordinal number of the test.
|
|
734
804
|
*/
|
|
@@ -751,6 +821,24 @@ declare module "node:test" {
|
|
|
751
821
|
* The nesting level of the test.
|
|
752
822
|
*/
|
|
753
823
|
nesting: number;
|
|
824
|
+
/**
|
|
825
|
+
* The `testId` of the enclosing test, or
|
|
826
|
+
* `undefined` for top-level tests. Lets custom reporters track lineage
|
|
827
|
+
* when concurrent siblings at the same nesting level interleave.
|
|
828
|
+
*/
|
|
829
|
+
parentId: number | undefined;
|
|
830
|
+
/**
|
|
831
|
+
* The flattened lowercased tags declared on the test
|
|
832
|
+
* and its ancestor suites, in declaration order. Empty for untagged tests.
|
|
833
|
+
* See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
834
|
+
*/
|
|
835
|
+
tags: string[];
|
|
836
|
+
/**
|
|
837
|
+
* A numeric identifier for this test instance, unique
|
|
838
|
+
* within the test file's process. Consistent across all events for the same
|
|
839
|
+
* test instance, enabling reliable correlation in custom reporters.
|
|
840
|
+
*/
|
|
841
|
+
testId: number;
|
|
754
842
|
/**
|
|
755
843
|
* The test type. Either `'suite'` or `'test'`.
|
|
756
844
|
* @since v22.15.0
|
|
@@ -766,6 +854,24 @@ declare module "node:test" {
|
|
|
766
854
|
* The nesting level of the test.
|
|
767
855
|
*/
|
|
768
856
|
nesting: number;
|
|
857
|
+
/**
|
|
858
|
+
* The `testId` of the enclosing test, or
|
|
859
|
+
* `undefined` for top-level tests. Lets custom reporters track lineage
|
|
860
|
+
* when concurrent siblings at the same nesting level interleave.
|
|
861
|
+
*/
|
|
862
|
+
parentId: number | undefined;
|
|
863
|
+
/**
|
|
864
|
+
* The flattened lowercased tags declared on the test
|
|
865
|
+
* and its ancestor suites, in declaration order. Empty for untagged tests.
|
|
866
|
+
* See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
867
|
+
*/
|
|
868
|
+
tags: string[];
|
|
869
|
+
/**
|
|
870
|
+
* A numeric identifier for this test instance, unique
|
|
871
|
+
* within the test file's process. Consistent across all events for the same
|
|
872
|
+
* test instance, enabling reliable correlation in custom reporters.
|
|
873
|
+
*/
|
|
874
|
+
testId: number;
|
|
769
875
|
/**
|
|
770
876
|
* The test type. Either `'suite'` or `'test'`.
|
|
771
877
|
* @since v22.15.0
|
|
@@ -805,6 +911,24 @@ declare module "node:test" {
|
|
|
805
911
|
* The nesting level of the test.
|
|
806
912
|
*/
|
|
807
913
|
nesting: number;
|
|
914
|
+
/**
|
|
915
|
+
* The `testId` of the enclosing test, or
|
|
916
|
+
* `undefined` for top-level tests. Lets custom reporters track lineage
|
|
917
|
+
* when concurrent siblings at the same nesting level interleave.
|
|
918
|
+
*/
|
|
919
|
+
parentId: number | undefined;
|
|
920
|
+
/**
|
|
921
|
+
* The flattened lowercased tags declared on the test
|
|
922
|
+
* and its ancestor suites, in declaration order. Empty for untagged tests.
|
|
923
|
+
* See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
924
|
+
*/
|
|
925
|
+
tags: string[];
|
|
926
|
+
/**
|
|
927
|
+
* A numeric identifier for this test instance, unique
|
|
928
|
+
* within the test file's process. Consistent across all events for the same
|
|
929
|
+
* test instance, enabling reliable correlation in custom reporters.
|
|
930
|
+
*/
|
|
931
|
+
testId: number;
|
|
808
932
|
/**
|
|
809
933
|
* The ordinal number of the test.
|
|
810
934
|
*/
|
|
@@ -818,6 +942,13 @@ declare module "node:test" {
|
|
|
818
942
|
*/
|
|
819
943
|
skip?: string | boolean;
|
|
820
944
|
}
|
|
945
|
+
interface TestInterrupted {
|
|
946
|
+
/**
|
|
947
|
+
* An array of objects containing information about the
|
|
948
|
+
* interrupted tests.
|
|
949
|
+
*/
|
|
950
|
+
tests: TestStart[];
|
|
951
|
+
}
|
|
821
952
|
interface TestPass extends LocationInfo {
|
|
822
953
|
/**
|
|
823
954
|
* Additional execution metadata.
|
|
@@ -853,6 +984,24 @@ declare module "node:test" {
|
|
|
853
984
|
* The nesting level of the test.
|
|
854
985
|
*/
|
|
855
986
|
nesting: number;
|
|
987
|
+
/**
|
|
988
|
+
* The `testId` of the enclosing test, or
|
|
989
|
+
* `undefined` for top-level tests. Lets custom reporters track lineage
|
|
990
|
+
* when concurrent siblings at the same nesting level interleave.
|
|
991
|
+
*/
|
|
992
|
+
parentId: number | undefined;
|
|
993
|
+
/**
|
|
994
|
+
* The flattened lowercased tags declared on the test
|
|
995
|
+
* and its ancestor suites, in declaration order. Empty for untagged tests.
|
|
996
|
+
* See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
997
|
+
*/
|
|
998
|
+
tags: string[];
|
|
999
|
+
/**
|
|
1000
|
+
* A numeric identifier for this test instance, unique
|
|
1001
|
+
* within the test file's process. Consistent across all events for the same
|
|
1002
|
+
* test instance, enabling reliable correlation in custom reporters.
|
|
1003
|
+
*/
|
|
1004
|
+
testId: number;
|
|
856
1005
|
/**
|
|
857
1006
|
* The ordinal number of the test.
|
|
858
1007
|
*/
|
|
@@ -885,6 +1034,24 @@ declare module "node:test" {
|
|
|
885
1034
|
* The nesting level of the test.
|
|
886
1035
|
*/
|
|
887
1036
|
nesting: number;
|
|
1037
|
+
/**
|
|
1038
|
+
* The `testId` of the enclosing test, or
|
|
1039
|
+
* `undefined` for top-level tests. Lets custom reporters track lineage
|
|
1040
|
+
* when concurrent siblings at the same nesting level interleave.
|
|
1041
|
+
*/
|
|
1042
|
+
parentId: number | undefined;
|
|
1043
|
+
/**
|
|
1044
|
+
* The flattened lowercased tags declared on the test
|
|
1045
|
+
* and its ancestor suites, in declaration order. Empty for untagged tests.
|
|
1046
|
+
* See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
1047
|
+
*/
|
|
1048
|
+
tags: string[];
|
|
1049
|
+
/**
|
|
1050
|
+
* A numeric identifier for this test instance, unique
|
|
1051
|
+
* within the test file's process. Consistent across all events for the same
|
|
1052
|
+
* test instance, enabling reliable correlation in custom reporters.
|
|
1053
|
+
*/
|
|
1054
|
+
testId: number;
|
|
888
1055
|
}
|
|
889
1056
|
interface TestStderr {
|
|
890
1057
|
/**
|
|
@@ -958,6 +1125,39 @@ declare module "node:test" {
|
|
|
958
1125
|
success: boolean;
|
|
959
1126
|
}
|
|
960
1127
|
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Returns the {@link TestContext} or {@link SuiteContext} object associated with the
|
|
1130
|
+
* currently executing test or suite, or `undefined` if called outside of a test or
|
|
1131
|
+
* suite. This function can be used to access context information from within the
|
|
1132
|
+
* test or suite function or any async operations within them.
|
|
1133
|
+
|
|
1134
|
+
* ```js
|
|
1135
|
+
* import { getTestContext } from 'node:test';
|
|
1136
|
+
*
|
|
1137
|
+
* test('example test', async () => {
|
|
1138
|
+
* const ctx = getTestContext();
|
|
1139
|
+
* console.log(`Running test: ${ctx.name}`);
|
|
1140
|
+
* });
|
|
1141
|
+
*
|
|
1142
|
+
* describe('example suite', () => {
|
|
1143
|
+
* const ctx = getTestContext();
|
|
1144
|
+
* console.log(`Running suite: ${ctx.name}`);
|
|
1145
|
+
* });
|
|
1146
|
+
* ```
|
|
1147
|
+
*
|
|
1148
|
+
* When called from a test, returns a `TestContext`.
|
|
1149
|
+
* When called from a suite, returns a `SuiteContext`.
|
|
1150
|
+
*
|
|
1151
|
+
* If called from outside a test or suite (e.g., at the top level of a module or in
|
|
1152
|
+
* a setTimeout callback after execution has completed), this function returns
|
|
1153
|
+
* `undefined`.
|
|
1154
|
+
*
|
|
1155
|
+
* When called from within a hook (before, beforeEach, after, afterEach), this
|
|
1156
|
+
* function returns the context of the test or suite that the hook is associated
|
|
1157
|
+
* with.
|
|
1158
|
+
* @since v24.19.0
|
|
1159
|
+
*/
|
|
1160
|
+
function getTestContext(): TestContext | SuiteContext | undefined;
|
|
961
1161
|
/**
|
|
962
1162
|
* An instance of `TestContext` is passed to each test function in order to
|
|
963
1163
|
* interact with the test runner. However, the `TestContext` constructor is not
|
|
@@ -989,6 +1189,41 @@ declare module "node:test" {
|
|
|
989
1189
|
*/
|
|
990
1190
|
readonly assert: TestContextAssert;
|
|
991
1191
|
readonly attempt: number;
|
|
1192
|
+
/**
|
|
1193
|
+
* A frozen array of the test's flattened lowercased tags, in declaration
|
|
1194
|
+
* order, including any tags inherited from ancestor suites. Empty when the
|
|
1195
|
+
* test has no tags. See [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
1196
|
+
* @since v24.19.0
|
|
1197
|
+
*/
|
|
1198
|
+
readonly tags: readonly string[];
|
|
1199
|
+
/**
|
|
1200
|
+
* The unique identifier of the worker running the current test file. This value is
|
|
1201
|
+
* derived from the `NODE_TEST_WORKER_ID` environment variable. When running tests
|
|
1202
|
+
* with `--test-isolation=process` (the default), each test file runs in a separate
|
|
1203
|
+
* child process and is assigned a worker ID from 1 to N, where N is the number of
|
|
1204
|
+
* concurrent workers. When running with `--test-isolation=none`, all tests run in
|
|
1205
|
+
* the same process and the worker ID is always 1. This value is `undefined` when
|
|
1206
|
+
* not running in a test context.
|
|
1207
|
+
*
|
|
1208
|
+
* This property is useful for splitting resources (like database connections or
|
|
1209
|
+
* server ports) across concurrent test files:
|
|
1210
|
+
*
|
|
1211
|
+
* ```js
|
|
1212
|
+
* import { test } from 'node:test';
|
|
1213
|
+
* import { process } from 'node:process';
|
|
1214
|
+
*
|
|
1215
|
+
* test('database operations', async (t) => {
|
|
1216
|
+
* // Worker ID is available via context
|
|
1217
|
+
* console.log(`Running in worker ${t.workerId}`);
|
|
1218
|
+
*
|
|
1219
|
+
* // Or via environment variable (available at import time)
|
|
1220
|
+
* const workerId = process.env.NODE_TEST_WORKER_ID;
|
|
1221
|
+
* // Use workerId to allocate separate resources per worker
|
|
1222
|
+
* });
|
|
1223
|
+
* ```
|
|
1224
|
+
* @since v24.15.0
|
|
1225
|
+
*/
|
|
1226
|
+
readonly workerId: number | undefined;
|
|
992
1227
|
/**
|
|
993
1228
|
* This function is used to create a hook running before subtest of the current test.
|
|
994
1229
|
* @param fn The hook function. The first argument to this function is a `TestContext` object.
|
|
@@ -1320,6 +1555,31 @@ declare module "node:test" {
|
|
|
1320
1555
|
* @since v18.7.0, v16.17.0
|
|
1321
1556
|
*/
|
|
1322
1557
|
readonly signal: AbortSignal;
|
|
1558
|
+
/**
|
|
1559
|
+
* Indicates whether the suite and all of its subtests have passed.
|
|
1560
|
+
* @since v24.16.0
|
|
1561
|
+
*/
|
|
1562
|
+
readonly passed: boolean;
|
|
1563
|
+
/**
|
|
1564
|
+
* The current attempt number of the suite. Used in conjunction with the
|
|
1565
|
+
* `--test-rerun-failures` option to determine the attempt number of the current
|
|
1566
|
+
* run.
|
|
1567
|
+
* @since v24.16.0
|
|
1568
|
+
*/
|
|
1569
|
+
readonly attempt: number;
|
|
1570
|
+
/**
|
|
1571
|
+
* Output a diagnostic message. This is typically used for logging information
|
|
1572
|
+
* about the current suite or its tests.
|
|
1573
|
+
*
|
|
1574
|
+
* ```js
|
|
1575
|
+
* test.describe('my suite', (suite) => {
|
|
1576
|
+
* suite.diagnostic('Suite diagnostic message');
|
|
1577
|
+
* });
|
|
1578
|
+
* ```
|
|
1579
|
+
* @since v24.16.0
|
|
1580
|
+
* @param message A diagnostic message to output.
|
|
1581
|
+
*/
|
|
1582
|
+
diagnostic(message: string): void;
|
|
1323
1583
|
}
|
|
1324
1584
|
interface TestOptions {
|
|
1325
1585
|
/**
|
|
@@ -1331,6 +1591,17 @@ declare module "node:test" {
|
|
|
1331
1591
|
* @default false
|
|
1332
1592
|
*/
|
|
1333
1593
|
concurrency?: number | boolean | undefined;
|
|
1594
|
+
/**
|
|
1595
|
+
* If truthy, the test is expected to fail. If a non-empty string is provided, that string is displayed
|
|
1596
|
+
* in the test results as the reason why the test is expected to fail. If a
|
|
1597
|
+
* `RegExp`, `Function`, `Object`, or `Error` is provided directly (without wrapping in `{ match: … }`), the test passes
|
|
1598
|
+
* only if the thrown error matches, following the behavior of
|
|
1599
|
+
* `assert.throws`. To provide both a reason and validation, pass an object
|
|
1600
|
+
* with `label` (string) and `match` (RegExp, Function, Object, or Error).
|
|
1601
|
+
* @since v24.15.0
|
|
1602
|
+
* @default false
|
|
1603
|
+
*/
|
|
1604
|
+
expectFailure?: boolean | string | AssertPredicate | undefined;
|
|
1334
1605
|
/**
|
|
1335
1606
|
* If truthy, and the test context is configured to run `only` tests, then this test will be
|
|
1336
1607
|
* run. Otherwise, the test is skipped.
|
|
@@ -1348,6 +1619,15 @@ declare module "node:test" {
|
|
|
1348
1619
|
* @default false
|
|
1349
1620
|
*/
|
|
1350
1621
|
skip?: boolean | string | undefined;
|
|
1622
|
+
/**
|
|
1623
|
+
* An array of string labels associated with the test.
|
|
1624
|
+
* Used together with `--experimental-test-tag-filter` to filter which
|
|
1625
|
+
* tests run. Tags inherit from suites to nested tests by union. See
|
|
1626
|
+
* [Test tags](https://nodejs.org/docs/latest-v24.x/api/test.html#test-tags).
|
|
1627
|
+
* @default []
|
|
1628
|
+
* @since v24.19.0
|
|
1629
|
+
*/
|
|
1630
|
+
tags?: readonly string[] | undefined;
|
|
1351
1631
|
/**
|
|
1352
1632
|
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
|
1353
1633
|
* value from their parent.
|
|
@@ -1494,19 +1774,40 @@ declare module "node:test" {
|
|
|
1494
1774
|
*/
|
|
1495
1775
|
cache?: boolean | undefined;
|
|
1496
1776
|
/**
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1501
|
-
* If
|
|
1777
|
+
* Optional mocked exports. The `default` property, if
|
|
1778
|
+
* provided, is used as the mocked module's default export. All other own
|
|
1779
|
+
* enumerable properties are used as named exports.
|
|
1780
|
+
* **This option cannot be used with `defaultExport` or `namedExports`.**
|
|
1781
|
+
* * If the mock is a CommonJS or builtin module, `exports.default` is used as
|
|
1782
|
+
* the value of `module.exports`.
|
|
1783
|
+
* * If `exports.default` is not provided for a CommonJS or builtin mock,
|
|
1784
|
+
* `module.exports` defaults to an empty object.
|
|
1785
|
+
* * If named exports are provided with a non-object default export, the mock
|
|
1786
|
+
* throws an exception when used as a CommonJS or builtin module.
|
|
1787
|
+
*/
|
|
1788
|
+
exports?: object | undefined;
|
|
1789
|
+
/**
|
|
1790
|
+
* An optional value used as the mocked module's default
|
|
1791
|
+
* export. If this value is not provided, ESM mocks do not include a default
|
|
1792
|
+
* export. If the mock is a CommonJS or builtin module, this setting is used as
|
|
1793
|
+
* the value of `module.exports`. If this value is not provided, CJS and builtin
|
|
1794
|
+
* mocks use an empty object as the value of `module.exports`.
|
|
1795
|
+
* **This option cannot be used with `options.exports`.**
|
|
1796
|
+
* This option is deprecated and will be removed in a later version.
|
|
1797
|
+
* Prefer `options.exports.default`.
|
|
1798
|
+
* @deprecated
|
|
1502
1799
|
*/
|
|
1503
1800
|
defaultExport?: any;
|
|
1504
1801
|
/**
|
|
1505
|
-
* An object whose keys and values are used to
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1802
|
+
* An optional object whose keys and values are used to
|
|
1803
|
+
* create the named exports of the mock module. If the mock is a CommonJS or
|
|
1804
|
+
* builtin module, these values are copied onto `module.exports`. Therefore, if a
|
|
1805
|
+
* mock is created with both named exports and a non-object default export, the
|
|
1806
|
+
* mock will throw an exception when used as a CJS or builtin module.
|
|
1807
|
+
* **This option cannot be used with `options.exports`.**
|
|
1808
|
+
* This option is deprecated and will be removed in a later version.
|
|
1809
|
+
* Prefer `options.exports`.
|
|
1810
|
+
* @deprecated
|
|
1510
1811
|
*/
|
|
1511
1812
|
namedExports?: object | undefined;
|
|
1512
1813
|
}
|
|
@@ -1681,14 +1982,19 @@ declare module "node:test" {
|
|
|
1681
1982
|
* [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--experimental-test-module-mocks)
|
|
1682
1983
|
* command-line flag.
|
|
1683
1984
|
*
|
|
1985
|
+
* **Note**: [module customization hooks](https://nodejs.org/docs/latest-v24.x/api/module.html#customization-hooks) registered via the **synchronous** API effect resolution of
|
|
1986
|
+
* the `specifier` provided to `mock.module`. Customization hooks registered via the **asynchronous**
|
|
1987
|
+
* API are currently ignored (because the test runner's loader is synchronous, and node does not
|
|
1988
|
+
* support multi-chain / cross-chain loading).
|
|
1989
|
+
*
|
|
1684
1990
|
* The following example demonstrates how a mock is created for a module.
|
|
1685
1991
|
*
|
|
1686
1992
|
* ```js
|
|
1687
1993
|
* test('mocks a builtin module in both module systems', async (t) => {
|
|
1688
|
-
* // Create a mock of 'node:readline' with a named export named '
|
|
1994
|
+
* // Create a mock of 'node:readline' with a named export named 'foo', which
|
|
1689
1995
|
* // does not exist in the original 'node:readline' module.
|
|
1690
1996
|
* const mock = t.mock.module('node:readline', {
|
|
1691
|
-
*
|
|
1997
|
+
* exports: { foo: () => 42 },
|
|
1692
1998
|
* });
|
|
1693
1999
|
*
|
|
1694
2000
|
* let esmImpl = await import('node:readline');
|
|
@@ -2295,6 +2601,7 @@ declare module "node:test/reporters" {
|
|
|
2295
2601
|
| { type: "test:diagnostic"; data: EventData.TestDiagnostic }
|
|
2296
2602
|
| { type: "test:enqueue"; data: EventData.TestEnqueue }
|
|
2297
2603
|
| { type: "test:fail"; data: EventData.TestFail }
|
|
2604
|
+
| { type: "test:interrupted"; data: EventData.TestInterrupted }
|
|
2298
2605
|
| { type: "test:pass"; data: EventData.TestPass }
|
|
2299
2606
|
| { type: "test:plan"; data: EventData.TestPlan }
|
|
2300
2607
|
| { type: "test:start"; data: EventData.TestStart }
|
|
@@ -273,11 +273,19 @@ declare module "tls" {
|
|
|
273
273
|
*/
|
|
274
274
|
getCipher(): CipherNameAndProtocol;
|
|
275
275
|
/**
|
|
276
|
-
* Returns an object
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
276
|
+
* Returns an object describing ephemeral key agreement in [perfect forward
|
|
277
|
+
* secrecy](https://nodejs.org/docs/latest-v26.x/api/tls.html#perfect-forward-secrecy) on a client connection. It returns an empty object when the key
|
|
278
|
+
* agreement is not ephemeral. As this is only supported on a client socket;
|
|
279
|
+
* `null` is returned if called on a server socket. The supported types are `'DH'`,
|
|
280
|
+
* `'ECDH'`, and `'TLSGroup'`. For `'DH'` and `'ECDH'`, the object describes peer
|
|
281
|
+
* temporary key parameters. For `'TLSGroup'`, the object identifies the negotiated
|
|
282
|
+
* TLS Supported Group used for key agreement when a peer temporary key object is
|
|
283
|
+
* not available.
|
|
284
|
+
*
|
|
285
|
+
* The `name` property is available only when type is `'ECDH'` or `'TLSGroup'`. The
|
|
286
|
+
* `size` property is not available when type is `'TLSGroup'`. For `'TLSGroup'`,
|
|
287
|
+
* `name` is the negotiated TLS Supported Group name. Standardized TLS group names
|
|
288
|
+
* and code points are listed in the [IANA TLS Supported Groups registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8).
|
|
281
289
|
*
|
|
282
290
|
* For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`.
|
|
283
291
|
* @since v5.0.0
|
|
@@ -832,6 +840,7 @@ declare module "tls" {
|
|
|
832
840
|
prependOnceListener(event: "keylog", listener: (line: NonSharedBuffer, tlsSocket: TLSSocket) => void): this;
|
|
833
841
|
}
|
|
834
842
|
type SecureVersion = "TLSv1.3" | "TLSv1.2" | "TLSv1.1" | "TLSv1";
|
|
843
|
+
type CertificateCompressionAlgorithm = "zlib" | "brotli" | "zstd";
|
|
835
844
|
interface SecureContextOptions {
|
|
836
845
|
/**
|
|
837
846
|
* If set, this will be called when a client opens a connection using the ALPN extension.
|
|
@@ -868,6 +877,15 @@ declare module "tls" {
|
|
|
868
877
|
* able to validate the certificate, and the handshake will fail.
|
|
869
878
|
*/
|
|
870
879
|
cert?: string | Buffer | Array<string | Buffer> | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* An array of supported certificate
|
|
882
|
+
* compression algorithm names, in preference order. Supported values are
|
|
883
|
+
* `'zlib'`, `'brotli'`, and `'zstd'`. When set, enables TLS certificate
|
|
884
|
+
* compression ([RFC 8879](https://tools.ietf.org/html/rfc8879)) which compresses certificates during the TLS
|
|
885
|
+
* handshake, reducing handshake size. Only effective with TLSv1.3.
|
|
886
|
+
* **Default:** `[]` (disabled).
|
|
887
|
+
*/
|
|
888
|
+
certificateCompression?: readonly CertificateCompressionAlgorithm[] | undefined;
|
|
871
889
|
/**
|
|
872
890
|
* Colon-separated list of supported signature algorithms. The list
|
|
873
891
|
* can contain digest algorithms (SHA256, MD5 etc.), public key
|
|
@@ -898,13 +916,16 @@ declare module "tls" {
|
|
|
898
916
|
*/
|
|
899
917
|
dhparam?: string | Buffer | undefined;
|
|
900
918
|
/**
|
|
901
|
-
* A string describing a named curve
|
|
902
|
-
*
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
919
|
+
* A string describing a named curve, TLS group, or
|
|
920
|
+
* colon-separated list of named curves or TLS groups to use for key agreement,
|
|
921
|
+
* for example `P-521:P-384:P-256`, `X25519`, or `X25519MLKEM768`. The
|
|
922
|
+
* historical name of this option refers to ECDH key agreement in TLSv1.2 and
|
|
923
|
+
* below. In TLSv1.3, this option configures the TLS Supported Groups and
|
|
924
|
+
* key share groups offered or accepted by the TLS stack. Set to `auto` to
|
|
925
|
+
* select the group automatically. Use `crypto.getCurves()` to obtain a
|
|
926
|
+
* list of available elliptic curve names. For TLS group names, use
|
|
927
|
+
* `openssl list -tls-groups` or consult the [IANA TLS Supported Groups
|
|
928
|
+
* registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8).
|
|
908
929
|
*/
|
|
909
930
|
ecdhCurve?: string | undefined;
|
|
910
931
|
/**
|
|
@@ -1196,6 +1217,20 @@ declare module "tls" {
|
|
|
1196
1217
|
* @since v0.10.2
|
|
1197
1218
|
*/
|
|
1198
1219
|
function getCiphers(): string[];
|
|
1220
|
+
/**
|
|
1221
|
+
* Returns an array with the names of the RFC 8879 certificate compression
|
|
1222
|
+
* algorithms supported by the current OpenSSL build, suitable for use in the
|
|
1223
|
+
* `certificateCompression` option of `tls.createSecureContext()`. Possible
|
|
1224
|
+
* values include `'zlib'`, `'brotli'`, and `'zstd'`.
|
|
1225
|
+
*
|
|
1226
|
+
* The array is empty when certificate compression is unavailable.
|
|
1227
|
+
*
|
|
1228
|
+
* ```js
|
|
1229
|
+
* console.log(tls.getCertificateCompressionAlgorithms()); // ['zlib', 'brotli', 'zstd']
|
|
1230
|
+
* ```
|
|
1231
|
+
* @since v24.19.0
|
|
1232
|
+
*/
|
|
1233
|
+
function getCertificateCompressionAlgorithms(): CertificateCompressionAlgorithm[];
|
|
1199
1234
|
/**
|
|
1200
1235
|
* Sets the default CA certificates used by Node.js TLS clients. If the provided
|
|
1201
1236
|
* certificates are parsed successfully, they will become the default CA
|
|
@@ -1229,9 +1264,9 @@ declare module "tls" {
|
|
|
1229
1264
|
*/
|
|
1230
1265
|
function setDefaultCACertificates(certs: ReadonlyArray<string | NodeJS.ArrayBufferView>): void;
|
|
1231
1266
|
/**
|
|
1232
|
-
* The default curve
|
|
1233
|
-
* The default value is `'auto'`. See `
|
|
1234
|
-
* information.
|
|
1267
|
+
* The default named curve or TLS group list to use for key agreement in a TLS
|
|
1268
|
+
* server. The default value is `'auto'`. See `tls.createSecureContext()` for
|
|
1269
|
+
* further information.
|
|
1235
1270
|
* @since v0.11.13
|
|
1236
1271
|
*/
|
|
1237
1272
|
let DEFAULT_ECDH_CURVE: string;
|
|
@@ -465,4 +465,9 @@ declare module "buffer" {
|
|
|
465
465
|
new(size: number): Buffer;
|
|
466
466
|
prototype: Buffer;
|
|
467
467
|
};
|
|
468
|
+
/**
|
|
469
|
+
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
|
|
470
|
+
* TypeScript versions earlier than 5.7.
|
|
471
|
+
*/
|
|
472
|
+
type BufferView<T extends NodeJS.ArrayBufferView> = Buffer;
|
|
468
473
|
}
|
|
@@ -53,10 +53,11 @@ declare module "tty" {
|
|
|
53
53
|
* Allows configuration of `tty.ReadStream` so that it operates as a raw device.
|
|
54
54
|
*
|
|
55
55
|
* When in raw mode, input is always available character-by-character, not
|
|
56
|
-
* including modifiers. Additionally, all special processing of characters
|
|
57
|
-
* terminal is disabled, including echoing input
|
|
56
|
+
* including modifiers. Additionally, all special processing of input characters
|
|
57
|
+
* by the terminal is disabled, including echoing input
|
|
58
58
|
* characters. Ctrl+C will no longer cause a `SIGINT` when
|
|
59
|
-
* in this mode.
|
|
59
|
+
* in this mode. This mode does not affect terminal output processing, such as
|
|
60
|
+
* newline translation on Unix terminals.
|
|
60
61
|
* @since v0.7.7
|
|
61
62
|
* @param mode If `true`, configures the `tty.ReadStream` to operate as a raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw`
|
|
62
63
|
* property will be set to the resulting mode.
|