@types/node 22.1.0 → 22.3.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/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 02 Aug 2024 11:07:10 GMT
11
+ * Last updated: Wed, 14 Aug 2024 07:35:57 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/buffer.d.ts CHANGED
@@ -170,6 +170,17 @@ declare module "buffer" {
170
170
  * @since v15.7.0, v14.18.0
171
171
  */
172
172
  arrayBuffer(): Promise<ArrayBuffer>;
173
+ /**
174
+ * The `blob.bytes()` method returns the byte of the `Blob` object as a `Promise<Uint8Array>`.
175
+ *
176
+ * ```js
177
+ * const blob = new Blob(['hello']);
178
+ * blob.bytes().then((bytes) => {
179
+ * console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ]
180
+ * });
181
+ * ```
182
+ */
183
+ bytes(): Promise<Uint8Array>;
173
184
  /**
174
185
  * Creates and returns a new `Blob` containing a subset of this `Blob` objects
175
186
  * data. The original `Blob` is not altered.
node/fs/promises.d.ts CHANGED
@@ -21,6 +21,8 @@ declare module "fs/promises" {
21
21
  Dir,
22
22
  Dirent,
23
23
  GlobOptions,
24
+ GlobOptionsWithFileTypes,
25
+ GlobOptionsWithoutFileTypes,
24
26
  MakeDirectoryOptions,
25
27
  Mode,
26
28
  ObjectEncodingOptions,
@@ -1243,7 +1245,19 @@ declare module "fs/promises" {
1243
1245
  /**
1244
1246
  * Retrieves the files matching the specified pattern.
1245
1247
  */
1246
- function glob(pattern: string | string[], options?: GlobOptions): AsyncIterableIterator<string>;
1248
+ function glob(pattern: string | string[]): AsyncIterableIterator<string>;
1249
+ function glob(
1250
+ pattern: string | string[],
1251
+ opt: GlobOptionsWithFileTypes,
1252
+ ): AsyncIterableIterator<Dirent>;
1253
+ function glob(
1254
+ pattern: string | string[],
1255
+ opt: GlobOptionsWithoutFileTypes,
1256
+ ): AsyncIterableIterator<string>;
1257
+ function glob(
1258
+ pattern: string | string[],
1259
+ opt: GlobOptions,
1260
+ ): AsyncIterableIterator<Dirent> | AsyncIterableIterator<string>;
1247
1261
  }
1248
1262
  declare module "node:fs/promises" {
1249
1263
  export * from "fs/promises";
node/fs.d.ts CHANGED
@@ -4324,6 +4324,18 @@ declare module "fs" {
4324
4324
  * Function to filter out files/directories. Return true to exclude the item, false to include it.
4325
4325
  */
4326
4326
  exclude?: ((fileName: string) => boolean) | undefined;
4327
+ /**
4328
+ * `true` if the glob should return paths as `Dirent`s, `false` otherwise.
4329
+ * @default false
4330
+ * @since v22.2.0
4331
+ */
4332
+ withFileTypes?: boolean | undefined;
4333
+ }
4334
+ export interface GlobOptionsWithFileTypes extends GlobOptions {
4335
+ withFileTypes: true;
4336
+ }
4337
+ export interface GlobOptionsWithoutFileTypes extends GlobOptions {
4338
+ withFileTypes?: false | undefined;
4327
4339
  }
4328
4340
  /**
4329
4341
  * Retrieves the files matching the specified pattern.
@@ -4332,15 +4344,46 @@ declare module "fs" {
4332
4344
  pattern: string | string[],
4333
4345
  callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
4334
4346
  ): void;
4347
+ export function glob(
4348
+ pattern: string | string[],
4349
+ options: GlobOptionsWithFileTypes,
4350
+ callback: (
4351
+ err: NodeJS.ErrnoException | null,
4352
+ matches: Dirent[],
4353
+ ) => void,
4354
+ ): void;
4355
+ export function glob(
4356
+ pattern: string | string[],
4357
+ options: GlobOptionsWithoutFileTypes,
4358
+ callback: (
4359
+ err: NodeJS.ErrnoException | null,
4360
+ matches: string[],
4361
+ ) => void,
4362
+ ): void;
4335
4363
  export function glob(
4336
4364
  pattern: string | string[],
4337
4365
  options: GlobOptions,
4338
- callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
4366
+ callback: (
4367
+ err: NodeJS.ErrnoException | null,
4368
+ matches: Dirent[] | string[],
4369
+ ) => void,
4339
4370
  ): void;
4340
4371
  /**
4341
4372
  * Retrieves the files matching the specified pattern.
4342
4373
  */
4343
- export function globSync(pattern: string | string[], options?: GlobOptions): string[];
4374
+ export function globSync(pattern: string | string[]): string[];
4375
+ export function globSync(
4376
+ pattern: string | string[],
4377
+ options: GlobOptionsWithFileTypes,
4378
+ ): Dirent[];
4379
+ export function globSync(
4380
+ pattern: string | string[],
4381
+ options: GlobOptionsWithoutFileTypes,
4382
+ ): string[];
4383
+ export function globSync(
4384
+ pattern: string | string[],
4385
+ options: GlobOptions,
4386
+ ): Dirent[] | string[];
4344
4387
  }
4345
4388
  declare module "node:fs" {
4346
4389
  export * from "fs";
node/globals.d.ts CHANGED
@@ -7,12 +7,14 @@ type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undi
7
7
  type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
8
8
  type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
9
9
  type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
10
+ type _MessageEvent = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").MessageEvent;
10
11
  type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
11
12
  : import("undici-types").RequestInit;
12
13
  type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
13
14
  : import("undici-types").ResponseInit;
14
15
  type _File = typeof globalThis extends { onmessage: any } ? {} : import("node:buffer").File;
15
16
  type _WebSocket = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").WebSocket;
17
+ type _EventSource = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").EventSource;
16
18
  // #endregion Fetch and friends
17
19
 
18
20
  declare global {
@@ -404,6 +406,13 @@ declare global {
404
406
  } ? T
405
407
  : typeof import("undici-types").Headers;
406
408
 
409
+ interface MessageEvent extends _MessageEvent {}
410
+ var MessageEvent: typeof globalThis extends {
411
+ onmessage: any;
412
+ MessageEvent: infer T;
413
+ } ? T
414
+ : typeof import("undici-types").MessageEvent;
415
+
407
416
  interface File extends _File {}
408
417
  var File: typeof globalThis extends {
409
418
  onmessage: any;
@@ -414,4 +423,11 @@ declare global {
414
423
  interface WebSocket extends _WebSocket {}
415
424
  var WebSocket: typeof globalThis extends { onmessage: any; WebSocket: infer T } ? T
416
425
  : typeof import("undici-types").WebSocket;
426
+
427
+ interface EventSource extends _EventSource {}
428
+ /**
429
+ * Only available through the [--experimental-eventsource](https://nodejs.org/api/cli.html#--experimental-eventsource) flag.
430
+ */
431
+ var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T
432
+ : typeof import("undici-types").EventSource;
417
433
  }
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "22.1.0",
3
+ "version": "22.3.0",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -210,8 +210,8 @@
210
210
  },
211
211
  "scripts": {},
212
212
  "dependencies": {
213
- "undici-types": "~6.13.0"
213
+ "undici-types": "~6.18.2"
214
214
  },
215
- "typesPublisherContentHash": "a016324027de394c0877c1d44c03999bacaa45ed9b7249649d03dd6b9bfe4e5b",
215
+ "typesPublisherContentHash": "620b8a407d4118e9931ab6e01ed7af87ce13d63daa46a4098fca6d43eaf853db",
216
216
  "typeScriptVersion": "4.8"
217
217
  }
node/perf_hooks.d.ts CHANGED
@@ -31,7 +31,17 @@
31
31
  */
32
32
  declare module "perf_hooks" {
33
33
  import { AsyncResource } from "node:async_hooks";
34
- type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http" | "dns" | "net";
34
+ type EntryType =
35
+ | "dns" // Node.js only
36
+ | "function" // Node.js only
37
+ | "gc" // Node.js only
38
+ | "http2" // Node.js only
39
+ | "http" // Node.js only
40
+ | "mark" // available on the Web
41
+ | "measure" // available on the Web
42
+ | "net" // Node.js only
43
+ | "node" // Node.js only
44
+ | "resource"; // available on the Web
35
45
  interface NodeGCPerformanceDetail {
36
46
  /**
37
47
  * When `performanceEntry.entryType` is equal to 'gc', the `performance.kind` property identifies
@@ -114,6 +124,7 @@ declare module "perf_hooks" {
114
124
  * @since v8.5.0
115
125
  */
116
126
  class PerformanceNodeTiming extends PerformanceEntry {
127
+ readonly entryType: "node";
117
128
  /**
118
129
  * The high resolution millisecond timestamp at which the Node.js process
119
130
  * completed bootstrapping. If bootstrapping has not yet finished, the property
@@ -270,6 +281,30 @@ declare module "perf_hooks" {
270
281
  * @param name
271
282
  */
272
283
  mark(name: string, options?: MarkOptions): PerformanceMark;
284
+ /**
285
+ * Creates a new `PerformanceResourceTiming` entry in the Resource Timeline.
286
+ * A `PerformanceResourceTiming` is a subclass of `PerformanceEntry` whose `performanceEntry.entryType` is always `'resource'`.
287
+ * Performance resources are used to mark moments in the Resource Timeline.
288
+ * @param timingInfo [Fetch Timing Info](https://fetch.spec.whatwg.org/#fetch-timing-info)
289
+ * @param requestedUrl The resource url
290
+ * @param initiatorType The initiator name, e.g: 'fetch'
291
+ * @param global
292
+ * @param cacheMode The cache mode must be an empty string ('') or 'local'
293
+ * @param bodyInfo [Fetch Response Body Info](https://fetch.spec.whatwg.org/#response-body-info)
294
+ * @param responseStatus The response's status code
295
+ * @param deliveryType The delivery type. Default: ''.
296
+ * @since v18.2.0, v16.17.0
297
+ */
298
+ markResourceTiming(
299
+ timingInfo: object,
300
+ requestedUrl: string,
301
+ initiatorType: string,
302
+ global: object,
303
+ cacheMode: "" | "local",
304
+ bodyInfo: object,
305
+ responseStatus: number,
306
+ deliveryType?: string,
307
+ ): PerformanceResourceTiming;
273
308
  /**
274
309
  * Creates a new PerformanceMeasure entry in the Performance Timeline.
275
310
  * A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
@@ -543,6 +578,7 @@ declare module "perf_hooks" {
543
578
  * @since v18.2.0, v16.17.0
544
579
  */
545
580
  class PerformanceResourceTiming extends PerformanceEntry {
581
+ readonly entryType: "resource";
546
582
  protected constructor();
547
583
  /**
548
584
  * The high resolution millisecond timestamp at immediately before dispatching the `fetch`
node/process.d.ts CHANGED
@@ -1,8 +1,121 @@
1
1
  declare module "process" {
2
- import * as net from "node:net";
3
- import * as os from "node:os";
4
2
  import * as tty from "node:tty";
5
3
  import { Worker } from "node:worker_threads";
4
+
5
+ interface BuiltInModule {
6
+ "assert": typeof import("assert");
7
+ "node:assert": typeof import("node:assert");
8
+ "assert/strict": typeof import("assert/strict");
9
+ "node:assert/strict": typeof import("node:assert/strict");
10
+ "async_hooks": typeof import("async_hooks");
11
+ "node:async_hooks": typeof import("node:async_hooks");
12
+ "buffer": typeof import("buffer");
13
+ "node:buffer": typeof import("node:buffer");
14
+ "child_process": typeof import("child_process");
15
+ "node:child_process": typeof import("node:child_process");
16
+ "cluster": typeof import("cluster");
17
+ "node:cluster": typeof import("node:cluster");
18
+ "console": typeof import("console");
19
+ "node:console": typeof import("node:console");
20
+ "constants": typeof import("constants");
21
+ "node:constants": typeof import("node:constants");
22
+ "crypto": typeof import("crypto");
23
+ "node:crypto": typeof import("node:crypto");
24
+ "dgram": typeof import("dgram");
25
+ "node:dgram": typeof import("node:dgram");
26
+ "diagnostics_channel": typeof import("diagnostics_channel");
27
+ "node:diagnostics_channel": typeof import("node:diagnostics_channel");
28
+ "dns": typeof import("dns");
29
+ "node:dns": typeof import("node:dns");
30
+ "dns/promises": typeof import("dns/promises");
31
+ "node:dns/promises": typeof import("node:dns/promises");
32
+ "domain": typeof import("domain");
33
+ "node:domain": typeof import("node:domain");
34
+ "events": typeof import("events");
35
+ "node:events": typeof import("node:events");
36
+ "fs": typeof import("fs");
37
+ "node:fs": typeof import("node:fs");
38
+ "fs/promises": typeof import("fs/promises");
39
+ "node:fs/promises": typeof import("node:fs/promises");
40
+ "http": typeof import("http");
41
+ "node:http": typeof import("node:http");
42
+ "http2": typeof import("http2");
43
+ "node:http2": typeof import("node:http2");
44
+ "https": typeof import("https");
45
+ "node:https": typeof import("node:https");
46
+ "inspector": typeof import("inspector");
47
+ "node:inspector": typeof import("node:inspector");
48
+ // FIXME: module is missed
49
+ // "inspector/promises": typeof import("inspector/promises");
50
+ // "node:inspector/promises": typeof import("node:inspector/promises");
51
+ "module": typeof import("module");
52
+ "node:module": typeof import("node:module");
53
+ "net": typeof import("net");
54
+ "node:net": typeof import("node:net");
55
+ "os": typeof import("os");
56
+ "node:os": typeof import("node:os");
57
+ "path": typeof import("path");
58
+ "node:path": typeof import("node:path");
59
+ "path/posix": typeof import("path/posix");
60
+ "node:path/posix": typeof import("node:path/posix");
61
+ "path/win32": typeof import("path/win32");
62
+ "node:path/win32": typeof import("node:path/win32");
63
+ "perf_hooks": typeof import("perf_hooks");
64
+ "node:perf_hooks": typeof import("node:perf_hooks");
65
+ "process": typeof import("process");
66
+ "node:process": typeof import("node:process");
67
+ "punycode": typeof import("punycode");
68
+ "node:punycode": typeof import("node:punycode");
69
+ "querystring": typeof import("querystring");
70
+ "node:querystring": typeof import("node:querystring");
71
+ "readline": typeof import("readline");
72
+ "node:readline": typeof import("node:readline");
73
+ "readline/promises": typeof import("readline/promises");
74
+ "node:readline/promises": typeof import("node:readline/promises");
75
+ "repl": typeof import("repl");
76
+ "node:repl": typeof import("node:repl");
77
+ "node:sea": typeof import("node:sea");
78
+ "stream": typeof import("stream");
79
+ "node:stream": typeof import("node:stream");
80
+ "stream/consumers": typeof import("stream/consumers");
81
+ "node:stream/consumers": typeof import("node:stream/consumers");
82
+ "stream/promises": typeof import("stream/promises");
83
+ "node:stream/promises": typeof import("node:stream/promises");
84
+ "stream/web": typeof import("stream/web");
85
+ "node:stream/web": typeof import("node:stream/web");
86
+ "string_decoder": typeof import("string_decoder");
87
+ "node:string_decoder": typeof import("node:string_decoder");
88
+ "node:test": typeof import("node:test");
89
+ "node:test/reporters": typeof import("node:test/reporters");
90
+ "timers": typeof import("timers");
91
+ "node:timers": typeof import("node:timers");
92
+ "timers/promises": typeof import("timers/promises");
93
+ "node:timers/promises": typeof import("node:timers/promises");
94
+ "tls": typeof import("tls");
95
+ "node:tls": typeof import("node:tls");
96
+ "trace_events": typeof import("trace_events");
97
+ "node:trace_events": typeof import("node:trace_events");
98
+ "tty": typeof import("tty");
99
+ "node:tty": typeof import("node:tty");
100
+ "url": typeof import("url");
101
+ "node:url": typeof import("node:url");
102
+ "util": typeof import("util");
103
+ "node:util": typeof import("node:util");
104
+ "sys": typeof import("util");
105
+ "node:sys": typeof import("node:util");
106
+ "util/types": typeof import("util/types");
107
+ "node:util/types": typeof import("node:util/types");
108
+ "v8": typeof import("v8");
109
+ "node:v8": typeof import("node:v8");
110
+ "vm": typeof import("vm");
111
+ "node:vm": typeof import("node:vm");
112
+ "wasi": typeof import("wasi");
113
+ "node:wasi": typeof import("node:wasi");
114
+ "worker_threads": typeof import("worker_threads");
115
+ "node:worker_threads": typeof import("node:worker_threads");
116
+ "zlib": typeof import("zlib");
117
+ "node:zlib": typeof import("node:zlib");
118
+ }
6
119
  global {
7
120
  var process: NodeJS.Process;
8
121
  namespace NodeJS {
@@ -793,6 +906,12 @@ declare module "process" {
793
906
  * @since v17.3.0, v16.14.0
794
907
  */
795
908
  getActiveResourcesInfo(): string[];
909
+ /**
910
+ * Provides a way to load built-in modules in a globally available function.
911
+ * @param id ID of the built-in module being requested.
912
+ */
913
+ getBuiltinModule<ID extends keyof BuiltInModule>(id: ID): BuiltInModule[ID];
914
+ getBuiltinModule(id: string): object | undefined;
796
915
  /**
797
916
  * The `process.getgid()` method returns the numerical group identity of the
798
917
  * process. (See [`getgid(2)`](http://man7.org/linux/man-pages/man2/getgid.2.html).)
node/test.d.ts CHANGED
@@ -144,7 +144,22 @@ declare module "node:test" {
144
144
  function test(options?: TestOptions, fn?: TestFn): Promise<void>;
145
145
  function test(fn?: TestFn): Promise<void>;
146
146
  namespace test {
147
- export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, suite, test, todo };
147
+ export {
148
+ after,
149
+ afterEach,
150
+ before,
151
+ beforeEach,
152
+ describe,
153
+ it,
154
+ mock,
155
+ only,
156
+ run,
157
+ skip,
158
+ snapshot,
159
+ suite,
160
+ test,
161
+ todo,
162
+ };
148
163
  }
149
164
  /**
150
165
  * The `suite()` function is imported from the `node:test` module.
@@ -461,6 +476,12 @@ declare module "node:test" {
461
476
  * @since v18.0.0, v16.17.0
462
477
  */
463
478
  class TestContext {
479
+ /**
480
+ * An object containing assertion methods bound to the test context.
481
+ * The top-level functions from the `node:assert` module are exposed here for the purpose of creating test plans.
482
+ * @since v22.2.0
483
+ */
484
+ readonly assert: TestContextAssert;
464
485
  /**
465
486
  * This function is used to create a hook running before subtest of the current test.
466
487
  * @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
@@ -503,11 +524,52 @@ declare module "node:test" {
503
524
  * @param message Message to be reported.
504
525
  */
505
526
  diagnostic(message: string): void;
527
+ /**
528
+ * The name of the test and each of its ancestors, separated by `>`.
529
+ * @since v22.3.0
530
+ */
531
+ readonly fullName: string;
506
532
  /**
507
533
  * The name of the test.
508
534
  * @since v18.8.0, v16.18.0
509
535
  */
510
536
  readonly name: string;
537
+ /**
538
+ * Used to set the number of assertions and subtests that are expected to run within the test.
539
+ * If the number of assertions and subtests that run does not match the expected count, the test will fail.
540
+ *
541
+ * To make sure assertions are tracked, the assert functions on `context.assert` must be used,
542
+ * instead of importing from the `node:assert` module.
543
+ * ```js
544
+ * test('top level test', (t) => {
545
+ * t.plan(2);
546
+ * t.assert.ok('some relevant assertion here');
547
+ * t.test('subtest', () => {});
548
+ * });
549
+ * ```
550
+ *
551
+ * When working with asynchronous code, the `plan` function can be used to ensure that the correct number of assertions are run:
552
+ * ```js
553
+ * test('planning with streams', (t, done) => {
554
+ * function* generate() {
555
+ * yield 'a';
556
+ * yield 'b';
557
+ * yield 'c';
558
+ * }
559
+ * const expected = ['a', 'b', 'c'];
560
+ * t.plan(expected.length);
561
+ * const stream = Readable.from(generate());
562
+ * stream.on('data', (chunk) => {
563
+ * t.assert.strictEqual(chunk, expected.shift());
564
+ * });
565
+ * stream.on('end', () => {
566
+ * done();
567
+ * });
568
+ * });
569
+ * ```
570
+ * @since v22.2.0
571
+ */
572
+ plan(count: number): void;
511
573
  /**
512
574
  * If `shouldRunOnlyTests` is truthy, the test context will only run tests that
513
575
  * have the `only` option set. Otherwise, all tests are run. If Node.js was not
@@ -584,6 +646,106 @@ declare module "node:test" {
584
646
  */
585
647
  readonly mock: MockTracker;
586
648
  }
649
+ interface TestContextAssert {
650
+ /**
651
+ * Identical to the `deepEqual` function from the `node:assert` module, but bound to the test context.
652
+ */
653
+ deepEqual: typeof import("node:assert").deepEqual;
654
+ /**
655
+ * Identical to the `deepStrictEqual` function from the `node:assert` module, but bound to the test context.
656
+ */
657
+ deepStrictEqual: typeof import("node:assert").deepStrictEqual;
658
+ /**
659
+ * Identical to the `doesNotMatch` function from the `node:assert` module, but bound to the test context.
660
+ */
661
+ doesNotMatch: typeof import("node:assert").doesNotMatch;
662
+ /**
663
+ * Identical to the `doesNotReject` function from the `node:assert` module, but bound to the test context.
664
+ */
665
+ doesNotReject: typeof import("node:assert").doesNotReject;
666
+ /**
667
+ * Identical to the `doesNotThrow` function from the `node:assert` module, but bound to the test context.
668
+ */
669
+ doesNotThrow: typeof import("node:assert").doesNotThrow;
670
+ /**
671
+ * Identical to the `equal` function from the `node:assert` module, but bound to the test context.
672
+ */
673
+ equal: typeof import("node:assert").equal;
674
+ /**
675
+ * Identical to the `fail` function from the `node:assert` module, but bound to the test context.
676
+ */
677
+ fail: typeof import("node:assert").fail;
678
+ /**
679
+ * Identical to the `ifError` function from the `node:assert` module, but bound to the test context.
680
+ */
681
+ ifError: typeof import("node:assert").ifError;
682
+ /**
683
+ * Identical to the `match` function from the `node:assert` module, but bound to the test context.
684
+ */
685
+ match: typeof import("node:assert").match;
686
+ /**
687
+ * Identical to the `notDeepEqual` function from the `node:assert` module, but bound to the test context.
688
+ */
689
+ notDeepEqual: typeof import("node:assert").notDeepEqual;
690
+ /**
691
+ * Identical to the `notDeepStrictEqual` function from the `node:assert` module, but bound to the test context.
692
+ */
693
+ notDeepStrictEqual: typeof import("node:assert").notDeepStrictEqual;
694
+ /**
695
+ * Identical to the `notEqual` function from the `node:assert` module, but bound to the test context.
696
+ */
697
+ notEqual: typeof import("node:assert").notEqual;
698
+ /**
699
+ * Identical to the `notStrictEqual` function from the `node:assert` module, but bound to the test context.
700
+ */
701
+ notStrictEqual: typeof import("node:assert").notStrictEqual;
702
+ /**
703
+ * Identical to the `ok` function from the `node:assert` module, but bound to the test context.
704
+ */
705
+ ok: typeof import("node:assert").ok;
706
+ /**
707
+ * Identical to the `rejects` function from the `node:assert` module, but bound to the test context.
708
+ */
709
+ rejects: typeof import("node:assert").rejects;
710
+ /**
711
+ * Identical to the `strictEqual` function from the `node:assert` module, but bound to the test context.
712
+ */
713
+ strictEqual: typeof import("node:assert").strictEqual;
714
+ /**
715
+ * Identical to the `throws` function from the `node:assert` module, but bound to the test context.
716
+ */
717
+ throws: typeof import("node:assert").throws;
718
+ /**
719
+ * This function implements assertions for snapshot testing.
720
+ * ```js
721
+ * test('snapshot test with default serialization', (t) => {
722
+ * t.assert.snapshot({ value1: 1, value2: 2 });
723
+ * });
724
+ *
725
+ * test('snapshot test with custom serialization', (t) => {
726
+ * t.assert.snapshot({ value3: 3, value4: 4 }, {
727
+ * serializers: [(value) => JSON.stringify(value)]
728
+ * });
729
+ * });
730
+ * ```
731
+ *
732
+ * Only available through the [--experimental-test-snapshots](https://nodejs.org/api/cli.html#--experimental-test-snapshots) flag.
733
+ * @since v22.3.0
734
+ * @experimental
735
+ */
736
+ snapshot(value: any, options?: AssertSnapshotOptions): void;
737
+ }
738
+ interface AssertSnapshotOptions {
739
+ /**
740
+ * An array of synchronous functions used to serialize `value` into a string.
741
+ * `value` is passed as the only argument to the first serializer function.
742
+ * The return value of each serializer is passed as input to the next serializer.
743
+ * Once all serializers have run, the resulting value is coerced to a string.
744
+ *
745
+ * If no serializers are provided, the test runner's default serializers are used.
746
+ */
747
+ serializers?: ReadonlyArray<(value: any) => any> | undefined;
748
+ }
587
749
 
588
750
  /**
589
751
  * An instance of `SuiteContext` is passed to each suite function in order to
@@ -643,6 +805,14 @@ declare module "node:test" {
643
805
  * @default false
644
806
  */
645
807
  todo?: boolean | string | undefined;
808
+ /**
809
+ * The number of assertions and subtests expected to be run in the test.
810
+ * If the number of assertions run in the test does not match the number
811
+ * specified in the plan, the test will fail.
812
+ * @default undefined
813
+ * @since v22.2.0
814
+ */
815
+ plan?: number | undefined;
646
816
  }
647
817
  /**
648
818
  * This function creates a hook that runs before executing a suite.
@@ -759,6 +929,30 @@ declare module "node:test" {
759
929
  type FunctionPropertyNames<T> = {
760
930
  [K in keyof T]: T[K] extends Function ? K : never;
761
931
  }[keyof T];
932
+ interface MockModuleOptions {
933
+ /**
934
+ * If false, each call to `require()` or `import()` generates a new mock module.
935
+ * If true, subsequent calls will return the same module mock, and the mock module is inserted into the CommonJS cache.
936
+ * @default false
937
+ */
938
+ cache?: boolean | undefined;
939
+ /**
940
+ * The value to use as the mocked module's default export.
941
+ *
942
+ * If this value is not provided, ESM mocks do not include a default export.
943
+ * If the mock is a CommonJS or builtin module, this setting is used as the value of `module.exports`.
944
+ * If this value is not provided, CJS and builtin mocks use an empty object as the value of `module.exports`.
945
+ */
946
+ defaultExport?: any;
947
+ /**
948
+ * An object whose keys and values are used to create the named exports of the mock module.
949
+ *
950
+ * If the mock is a CommonJS or builtin module, these values are copied onto `module.exports`.
951
+ * Therefore, if a mock is created with both named exports and a non-object default export,
952
+ * the mock will throw an exception when used as a CJS or builtin module.
953
+ */
954
+ namedExports?: object | undefined;
955
+ }
762
956
  /**
763
957
  * The `MockTracker` class is used to manage mocking functionality. The test runner
764
958
  * module provides a top level `mock` export which is a `MockTracker` instance.
@@ -922,6 +1116,18 @@ declare module "node:test" {
922
1116
  options?: MockFunctionOptions,
923
1117
  ): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
924
1118
 
1119
+ /**
1120
+ * This function is used to mock the exports of ECMAScript modules, CommonJS modules, and Node.js builtin modules.
1121
+ * Any references to the original module prior to mocking are not impacted.
1122
+ *
1123
+ * Only available through the [--experimental-test-module-mocks](https://nodejs.org/api/cli.html#--experimental-test-module-mocks) flag.
1124
+ * @since v22.3.0
1125
+ * @experimental
1126
+ * @param specifier A string identifying the module to mock.
1127
+ * @param options Optional configuration options for the mock module.
1128
+ */
1129
+ module(specifier: string, options?: MockModuleOptions): MockModuleContext;
1130
+
925
1131
  /**
926
1132
  * This function restores the default behavior of all mocks that were previously
927
1133
  * 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
@@ -1081,6 +1287,17 @@ declare module "node:test" {
1081
1287
  */
1082
1288
  restore(): void;
1083
1289
  }
1290
+ /**
1291
+ * @since v22.3.0
1292
+ * @experimental
1293
+ */
1294
+ class MockModuleContext {
1295
+ /**
1296
+ * Resets the implementation of the mock module.
1297
+ * @since v22.3.0
1298
+ */
1299
+ restore(): void;
1300
+ }
1084
1301
 
1085
1302
  type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date";
1086
1303
  interface MockTimersOptions {
@@ -1303,6 +1520,35 @@ declare module "node:test" {
1303
1520
  */
1304
1521
  [Symbol.dispose](): void;
1305
1522
  }
1523
+ /**
1524
+ * Only available through the [--experimental-test-snapshots](https://nodejs.org/api/cli.html#--experimental-test-snapshots) flag.
1525
+ * @since v22.3.0
1526
+ * @experimental
1527
+ */
1528
+ namespace snapshot {
1529
+ /**
1530
+ * This function is used to customize the default serialization mechanism used by the test runner.
1531
+ *
1532
+ * By default, the test runner performs serialization by calling `JSON.stringify(value, null, 2)` on the provided value.
1533
+ * `JSON.stringify()` does have limitations regarding circular structures and supported data types.
1534
+ * If a more robust serialization mechanism is required, this function should be used to specify a list of custom serializers.
1535
+ *
1536
+ * Serializers are called in order, with the output of the previous serializer passed as input to the next.
1537
+ * The final result must be a string value.
1538
+ * @since v22.3.0
1539
+ * @param serializers An array of synchronous functions used as the default serializers for snapshot tests.
1540
+ */
1541
+ function setDefaultSnapshotSerializers(serializers: ReadonlyArray<(value: any) => any>): void;
1542
+ /**
1543
+ * This function is used to set a custom resolver for the location of the snapshot file used for snapshot testing.
1544
+ * By default, the snapshot filename is the same as the entry point filename with `.snapshot` appended.
1545
+ * @since v22.3.0
1546
+ * @param fn A function which returns a string specifying the location of the snapshot file.
1547
+ * The function receives the path of the test file as its only argument.
1548
+ * If `process.argv[1]` is not associated with a file (for example in the REPL), the input is undefined.
1549
+ */
1550
+ function setResolveSnapshotPath(fn: (path: string | undefined) => string): void;
1551
+ }
1306
1552
  export {
1307
1553
  after,
1308
1554
  afterEach,
@@ -1315,6 +1561,7 @@ declare module "node:test" {
1315
1561
  only,
1316
1562
  run,
1317
1563
  skip,
1564
+ snapshot,
1318
1565
  suite,
1319
1566
  SuiteContext,
1320
1567
  test,
node/zlib.d.ts CHANGED
@@ -172,6 +172,15 @@ declare module "zlib" {
172
172
  interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams {}
173
173
  interface InflateRaw extends stream.Transform, Zlib, ZlibReset {}
174
174
  interface Unzip extends stream.Transform, Zlib {}
175
+ /**
176
+ * Computes a 32-bit [Cyclic Redundancy Check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) checksum of `data`.
177
+ * If `value` is specified, it is used as the starting value of the checksum, otherwise, 0 is used as the starting value.
178
+ * @param data When `data` is a string, it will be encoded as UTF-8 before being used for computation.
179
+ * @param value An optional starting value. It must be a 32-bit unsigned integer. @default 0
180
+ * @returns A 32-bit unsigned integer containing the checksum.
181
+ * @since v22.2.0
182
+ */
183
+ function crc32(data: string | Buffer | NodeJS.ArrayBufferView, value?: number): number;
175
184
  /**
176
185
  * Creates and returns a new `BrotliCompress` object.
177
186
  * @since v11.7.0, v10.16.0