@types/node 22.0.2 → 22.1.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 +1 -1
- node/dns/promises.d.ts +10 -10
- node/dns.d.ts +24 -11
- node/package.json +3 -3
- node/test.d.ts +102 -78
- node/url.d.ts +27 -2
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:
|
11
|
+
* Last updated: Fri, 02 Aug 2024 11:07:10 GMT
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
13
13
|
|
14
14
|
# Credits
|
node/dns/promises.d.ts
CHANGED
@@ -346,20 +346,20 @@ declare module "dns/promises" {
|
|
346
346
|
*/
|
347
347
|
function setServers(servers: readonly string[]): void;
|
348
348
|
/**
|
349
|
-
* Set the default value of `
|
350
|
-
* The value could be:
|
349
|
+
* Set the default value of `order` in `dns.lookup()` and `{@link lookup}`. The value could be:
|
351
350
|
*
|
352
|
-
* * `ipv4first`: sets default `
|
353
|
-
* * `
|
351
|
+
* * `ipv4first`: sets default `order` to `ipv4first`.
|
352
|
+
* * `ipv6first`: sets default `order` to `ipv6first`.
|
353
|
+
* * `verbatim`: sets default `order` to `verbatim`.
|
354
354
|
*
|
355
|
-
* The default is `verbatim` and
|
356
|
-
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-
|
357
|
-
* [worker threads](https://nodejs.org/docs/latest-
|
358
|
-
* thread won't affect the default dns orders in workers.
|
355
|
+
* The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
|
356
|
+
* have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).
|
357
|
+
* When using [worker threads](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html), [`dnsPromises.setDefaultResultOrder()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
|
358
|
+
* from the main thread won't affect the default dns orders in workers.
|
359
359
|
* @since v16.4.0, v14.18.0
|
360
|
-
* @param order must be `'ipv4first'` or `'verbatim'`.
|
360
|
+
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
|
361
361
|
*/
|
362
|
-
function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
362
|
+
function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
|
363
363
|
// Error codes
|
364
364
|
const NODATA: "ENODATA";
|
365
365
|
const FORMERR: "EFORMERR";
|
node/dns.d.ts
CHANGED
@@ -80,11 +80,21 @@ declare module "dns" {
|
|
80
80
|
* @default false
|
81
81
|
*/
|
82
82
|
all?: boolean | undefined;
|
83
|
+
/**
|
84
|
+
* When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
|
85
|
+
* by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
|
86
|
+
* addresses before IPv4 addresses. Default value is configurable using
|
87
|
+
* {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder).
|
88
|
+
* @default `verbatim` (addresses are not reordered)
|
89
|
+
* @since v22.1.0
|
90
|
+
*/
|
91
|
+
order?: "ipv4first" | "ipv6first" | "verbatim" | undefined;
|
83
92
|
/**
|
84
93
|
* When `true`, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When `false`, IPv4
|
85
|
-
* addresses are placed before IPv6 addresses.
|
86
|
-
*
|
87
|
-
* @default true
|
94
|
+
* addresses are placed before IPv6 addresses. This option will be deprecated in favor of `order`. When both are specified,
|
95
|
+
* `order` has higher precedence. New code should only use `order`. Default value is configurable using {@link setDefaultResultOrder}
|
96
|
+
* @default true (addresses are not reordered)
|
97
|
+
* @deprecated Please use `order` option
|
88
98
|
*/
|
89
99
|
verbatim?: boolean | undefined;
|
90
100
|
}
|
@@ -663,14 +673,15 @@ declare module "dns" {
|
|
663
673
|
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
|
664
674
|
): void;
|
665
675
|
/**
|
666
|
-
* Get the default value for `
|
676
|
+
* Get the default value for `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
|
667
677
|
* The value could be:
|
668
678
|
*
|
669
|
-
* * `ipv4first`: for `
|
670
|
-
* * `
|
679
|
+
* * `ipv4first`: for `order` defaulting to `ipv4first`.
|
680
|
+
* * `ipv6first`: for `order` defaulting to `ipv6first`.
|
681
|
+
* * `verbatim`: for `order` defaulting to `verbatim`.
|
671
682
|
* @since v18.17.0
|
672
683
|
*/
|
673
|
-
export function getDefaultResultOrder(): "ipv4first" | "verbatim";
|
684
|
+
export function getDefaultResultOrder(): "ipv4first" | "ipv6first" | "verbatim";
|
674
685
|
/**
|
675
686
|
* Sets the IP address and port of servers to be used when performing DNS
|
676
687
|
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
@@ -717,19 +728,21 @@ declare module "dns" {
|
|
717
728
|
*/
|
718
729
|
export function getServers(): string[];
|
719
730
|
/**
|
720
|
-
* Set the default value of `
|
731
|
+
* Set the default value of `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options).
|
721
732
|
* The value could be:
|
722
733
|
*
|
723
|
-
* * `ipv4first`: sets default `
|
724
|
-
* * `
|
734
|
+
* * `ipv4first`: sets default `order` to `ipv4first`.
|
735
|
+
* * `ipv6first`: sets default `order` to `ipv6first`.
|
736
|
+
* * `verbatim`: sets default `order` to `verbatim`.
|
725
737
|
*
|
726
738
|
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
|
727
739
|
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder). When using
|
728
740
|
* [worker threads](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
|
729
741
|
* thread won't affect the default dns orders in workers.
|
730
742
|
* @since v16.4.0, v14.18.0
|
743
|
+
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
|
731
744
|
*/
|
732
|
-
export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
745
|
+
export function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
|
733
746
|
// Error codes
|
734
747
|
export const NODATA: "ENODATA";
|
735
748
|
export const FORMERR: "EFORMERR";
|
node/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/node",
|
3
|
-
"version": "22.0
|
3
|
+
"version": "22.1.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.
|
213
|
+
"undici-types": "~6.13.0"
|
214
214
|
},
|
215
|
-
"typesPublisherContentHash": "
|
215
|
+
"typesPublisherContentHash": "a016324027de394c0877c1d44c03999bacaa45ed9b7249649d03dd6b9bfe4e5b",
|
216
216
|
"typeScriptVersion": "4.8"
|
217
217
|
}
|
node/test.d.ts
CHANGED
@@ -80,7 +80,6 @@
|
|
80
80
|
*/
|
81
81
|
declare module "node:test" {
|
82
82
|
import { Readable } from "node:stream";
|
83
|
-
import { AsyncResource } from "node:async_hooks";
|
84
83
|
/**
|
85
84
|
* **Note:** `shard` is used to horizontally parallelize test running across
|
86
85
|
* machines or processes, ideal for large-scale executions across varied
|
@@ -98,7 +97,7 @@ declare module "node:test" {
|
|
98
97
|
* .pipe(process.stdout);
|
99
98
|
* ```
|
100
99
|
* @since v18.9.0, v16.19.0
|
101
|
-
* @param options Configuration options for running tests.
|
100
|
+
* @param options Configuration options for running tests.
|
102
101
|
*/
|
103
102
|
function run(options?: RunOptions): TestsStream;
|
104
103
|
/**
|
@@ -133,10 +132,11 @@ declare module "node:test" {
|
|
133
132
|
* canceling tests because a running test might block the application thread and
|
134
133
|
* thus prevent the scheduled cancellation.
|
135
134
|
* @since v18.0.0, v16.17.0
|
136
|
-
* @param
|
137
|
-
*
|
138
|
-
* @param
|
139
|
-
*
|
135
|
+
* @param name The name of the test, which is displayed when reporting test results.
|
136
|
+
* Defaults to the `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.
|
137
|
+
* @param options Configuration options for the test.
|
138
|
+
* @param fn The function under test. The first argument to this function is a {@link TestContext} object.
|
139
|
+
* If the test uses callbacks, the callback function is passed as the second argument.
|
140
140
|
* @return Fulfilled with `undefined` once the test completes, or immediately if the test runs within a suite.
|
141
141
|
*/
|
142
142
|
function test(name?: string, fn?: TestFn): Promise<void>;
|
@@ -148,9 +148,10 @@ declare module "node:test" {
|
|
148
148
|
}
|
149
149
|
/**
|
150
150
|
* The `suite()` function is imported from the `node:test` module.
|
151
|
-
* @param name The name of the suite, which is displayed when reporting test results.
|
152
|
-
*
|
153
|
-
* @param
|
151
|
+
* @param name The name of the suite, which is displayed when reporting test results.
|
152
|
+
* Defaults to the `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.
|
153
|
+
* @param options Configuration options for the suite. This supports the same options as {@link test}.
|
154
|
+
* @param fn The suite function declaring nested tests and suites. The first argument to this function is a {@link SuiteContext} object.
|
154
155
|
* @return Immediately fulfilled with `undefined`.
|
155
156
|
* @since v20.13.0
|
156
157
|
*/
|
@@ -160,7 +161,7 @@ declare module "node:test" {
|
|
160
161
|
function suite(fn?: SuiteFn): Promise<void>;
|
161
162
|
namespace suite {
|
162
163
|
/**
|
163
|
-
* Shorthand for skipping a suite. This is the same as
|
164
|
+
* Shorthand for skipping a suite. This is the same as calling {@link suite} with `options.skip` set to `true`.
|
164
165
|
* @since v20.13.0
|
165
166
|
*/
|
166
167
|
function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
@@ -168,7 +169,7 @@ declare module "node:test" {
|
|
168
169
|
function skip(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
169
170
|
function skip(fn?: SuiteFn): Promise<void>;
|
170
171
|
/**
|
171
|
-
* Shorthand for marking a suite as `TODO`. This is the same as
|
172
|
+
* Shorthand for marking a suite as `TODO`. This is the same as calling {@link suite} with `options.todo` set to `true`.
|
172
173
|
* @since v20.13.0
|
173
174
|
*/
|
174
175
|
function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
@@ -176,7 +177,7 @@ declare module "node:test" {
|
|
176
177
|
function todo(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
177
178
|
function todo(fn?: SuiteFn): Promise<void>;
|
178
179
|
/**
|
179
|
-
* Shorthand for marking a suite as `only`. This is the same as
|
180
|
+
* Shorthand for marking a suite as `only`. This is the same as calling {@link suite} with `options.only` set to `true`.
|
180
181
|
* @since v20.13.0
|
181
182
|
*/
|
182
183
|
function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
@@ -185,7 +186,7 @@ declare module "node:test" {
|
|
185
186
|
function only(fn?: SuiteFn): Promise<void>;
|
186
187
|
}
|
187
188
|
/**
|
188
|
-
* Alias for
|
189
|
+
* Alias for {@link suite}.
|
189
190
|
*
|
190
191
|
* The `describe()` function is imported from the `node:test` module.
|
191
192
|
*/
|
@@ -195,7 +196,7 @@ declare module "node:test" {
|
|
195
196
|
function describe(fn?: SuiteFn): Promise<void>;
|
196
197
|
namespace describe {
|
197
198
|
/**
|
198
|
-
* Shorthand for skipping a suite. This is the same as
|
199
|
+
* Shorthand for skipping a suite. This is the same as calling {@link describe} with `options.skip` set to `true`.
|
199
200
|
* @since v18.15.0
|
200
201
|
*/
|
201
202
|
function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
@@ -203,7 +204,7 @@ declare module "node:test" {
|
|
203
204
|
function skip(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
204
205
|
function skip(fn?: SuiteFn): Promise<void>;
|
205
206
|
/**
|
206
|
-
* Shorthand for marking a suite as `TODO`. This is the same as
|
207
|
+
* Shorthand for marking a suite as `TODO`. This is the same as calling {@link describe} with `options.todo` set to `true`.
|
207
208
|
* @since v18.15.0
|
208
209
|
*/
|
209
210
|
function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
@@ -211,7 +212,7 @@ declare module "node:test" {
|
|
211
212
|
function todo(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
212
213
|
function todo(fn?: SuiteFn): Promise<void>;
|
213
214
|
/**
|
214
|
-
* Shorthand for marking a suite as `only`. This is the same as
|
215
|
+
* Shorthand for marking a suite as `only`. This is the same as calling {@link describe} with `options.only` set to `true`.
|
215
216
|
* @since v18.15.0
|
216
217
|
*/
|
217
218
|
function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
@@ -220,7 +221,7 @@ declare module "node:test" {
|
|
220
221
|
function only(fn?: SuiteFn): Promise<void>;
|
221
222
|
}
|
222
223
|
/**
|
223
|
-
* Alias for
|
224
|
+
* Alias for {@link test}.
|
224
225
|
*
|
225
226
|
* The `it()` function is imported from the `node:test` module.
|
226
227
|
* @since v18.6.0, v16.17.0
|
@@ -231,21 +232,21 @@ declare module "node:test" {
|
|
231
232
|
function it(fn?: TestFn): Promise<void>;
|
232
233
|
namespace it {
|
233
234
|
/**
|
234
|
-
* Shorthand for skipping a test
|
235
|
+
* Shorthand for skipping a test. This is the same as calling {@link it} with `options.skip` set to `true`.
|
235
236
|
*/
|
236
237
|
function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
237
238
|
function skip(name?: string, fn?: TestFn): Promise<void>;
|
238
239
|
function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
|
239
240
|
function skip(fn?: TestFn): Promise<void>;
|
240
241
|
/**
|
241
|
-
* Shorthand for marking a test as `TODO
|
242
|
+
* Shorthand for marking a test as `TODO`. This is the same as calling {@link it} with `options.todo` set to `true`.
|
242
243
|
*/
|
243
244
|
function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
244
245
|
function todo(name?: string, fn?: TestFn): Promise<void>;
|
245
246
|
function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
|
246
247
|
function todo(fn?: TestFn): Promise<void>;
|
247
248
|
/**
|
248
|
-
* Shorthand for marking a test as `only
|
249
|
+
* Shorthand for marking a test as `only`. This is the same as calling {@link it} with `options.only` set to `true`.
|
249
250
|
* @since v18.15.0
|
250
251
|
*/
|
251
252
|
function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
@@ -254,7 +255,7 @@ declare module "node:test" {
|
|
254
255
|
function only(fn?: TestFn): Promise<void>;
|
255
256
|
}
|
256
257
|
/**
|
257
|
-
* Shorthand for skipping a test
|
258
|
+
* Shorthand for skipping a test. This is the same as calling {@link test} with `options.skip` set to `true`.
|
258
259
|
* @since v20.2.0
|
259
260
|
*/
|
260
261
|
function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
@@ -262,7 +263,7 @@ declare module "node:test" {
|
|
262
263
|
function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
|
263
264
|
function skip(fn?: TestFn): Promise<void>;
|
264
265
|
/**
|
265
|
-
* Shorthand for marking a test as `TODO
|
266
|
+
* Shorthand for marking a test as `TODO`. This is the same as calling {@link test} with `options.todo` set to `true`.
|
266
267
|
* @since v20.2.0
|
267
268
|
*/
|
268
269
|
function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
@@ -270,7 +271,7 @@ declare module "node:test" {
|
|
270
271
|
function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
|
271
272
|
function todo(fn?: TestFn): Promise<void>;
|
272
273
|
/**
|
273
|
-
* Shorthand for marking a test as `only
|
274
|
+
* Shorthand for marking a test as `only`. This is the same as calling {@link test} with `options.only` set to `true`.
|
274
275
|
* @since v20.2.0
|
275
276
|
*/
|
276
277
|
function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
@@ -278,18 +279,17 @@ declare module "node:test" {
|
|
278
279
|
function only(options?: TestOptions, fn?: TestFn): Promise<void>;
|
279
280
|
function only(fn?: TestFn): Promise<void>;
|
280
281
|
/**
|
281
|
-
* The type of a function
|
282
|
-
*
|
283
|
-
* the second argument.
|
282
|
+
* The type of a function passed to {@link test}. The first argument to this function is a {@link TestContext} object.
|
283
|
+
* If the test uses callbacks, the callback function is passed as the second argument.
|
284
284
|
*/
|
285
285
|
type TestFn = (t: TestContext, done: (result?: any) => void) => void | Promise<void>;
|
286
286
|
/**
|
287
|
-
* The type of a function
|
287
|
+
* The type of a suite test function. The argument to this function is a {@link SuiteContext} object.
|
288
288
|
*/
|
289
289
|
type SuiteFn = (s: SuiteContext) => void | Promise<void>;
|
290
290
|
interface TestShard {
|
291
291
|
/**
|
292
|
-
* A positive integer between 1 and
|
292
|
+
* A positive integer between 1 and `total` that specifies the index of the shard to run.
|
293
293
|
*/
|
294
294
|
index: number;
|
295
295
|
/**
|
@@ -305,7 +305,7 @@ declare module "node:test" {
|
|
305
305
|
*/
|
306
306
|
concurrency?: number | boolean | undefined;
|
307
307
|
/**
|
308
|
-
* An array containing the list of files to run.
|
308
|
+
* An array containing the list of files to run. If omitted, files are run according to the
|
309
309
|
* [test runner execution model](https://nodejs.org/docs/latest-v22.x/api/test.html#test-runner-execution-model).
|
310
310
|
*/
|
311
311
|
files?: readonly string[] | undefined;
|
@@ -326,26 +326,33 @@ declare module "node:test" {
|
|
326
326
|
/**
|
327
327
|
* If truthy, the test context will only run tests that have the `only` option set
|
328
328
|
*/
|
329
|
-
only?: boolean;
|
329
|
+
only?: boolean | undefined;
|
330
330
|
/**
|
331
331
|
* A function that accepts the `TestsStream` instance and can be used to setup listeners before any tests are run.
|
332
332
|
* @default undefined
|
333
333
|
*/
|
334
|
-
setup?: (
|
334
|
+
setup?: ((reporter: TestsStream) => void | Promise<void>) | undefined;
|
335
335
|
/**
|
336
336
|
* Allows aborting an in-progress test execution.
|
337
337
|
*/
|
338
338
|
signal?: AbortSignal | undefined;
|
339
339
|
/**
|
340
|
-
*
|
340
|
+
* If provided, only run tests whose name matches the provided pattern.
|
341
|
+
* Strings are interpreted as JavaScript regular expressions.
|
342
|
+
* @default undefined
|
343
|
+
*/
|
344
|
+
testNamePatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
|
345
|
+
/**
|
346
|
+
* A String, RegExp or a RegExp Array, that can be used to exclude running tests whose
|
341
347
|
* name matches the provided pattern. Test name patterns are interpreted as JavaScript
|
342
348
|
* regular expressions. For each test that is executed, any corresponding test hooks,
|
343
349
|
* such as `beforeEach()`, are also run.
|
344
350
|
* @default undefined
|
351
|
+
* @since v22.1.0
|
345
352
|
*/
|
346
|
-
|
353
|
+
testSkipPatterns?: string | RegExp | ReadonlyArray<string | RegExp> | undefined;
|
347
354
|
/**
|
348
|
-
*
|
355
|
+
* The number of milliseconds after which the test execution will fail.
|
349
356
|
* If unspecified, subtests inherit this value from their parent.
|
350
357
|
* @default Infinity
|
351
358
|
*/
|
@@ -361,18 +368,8 @@ declare module "node:test" {
|
|
361
368
|
*/
|
362
369
|
shard?: TestShard | undefined;
|
363
370
|
}
|
364
|
-
class Test extends AsyncResource {
|
365
|
-
concurrency: number;
|
366
|
-
nesting: number;
|
367
|
-
only: boolean;
|
368
|
-
reporter: TestsStream;
|
369
|
-
runOnlySubtests: boolean;
|
370
|
-
testNumber: number;
|
371
|
-
timeout: number | null;
|
372
|
-
}
|
373
371
|
/**
|
374
|
-
* A successful call to `run()`
|
375
|
-
* order of the tests definition
|
372
|
+
* A successful call to `run()` will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.
|
376
373
|
*
|
377
374
|
* Some of the events are guaranteed to be emitted in the same order as the tests are defined, while others are emitted in the order that the tests execute.
|
378
375
|
* @since v18.9.0, v16.19.0
|
@@ -389,6 +386,7 @@ declare module "node:test" {
|
|
389
386
|
addListener(event: "test:start", listener: (data: TestStart) => void): this;
|
390
387
|
addListener(event: "test:stderr", listener: (data: TestStderr) => void): this;
|
391
388
|
addListener(event: "test:stdout", listener: (data: TestStdout) => void): this;
|
389
|
+
addListener(event: "test:watch:drained", listener: () => void): this;
|
392
390
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
393
391
|
emit(event: "test:coverage", data: TestCoverage): boolean;
|
394
392
|
emit(event: "test:complete", data: TestComplete): boolean;
|
@@ -401,6 +399,7 @@ declare module "node:test" {
|
|
401
399
|
emit(event: "test:start", data: TestStart): boolean;
|
402
400
|
emit(event: "test:stderr", data: TestStderr): boolean;
|
403
401
|
emit(event: "test:stdout", data: TestStdout): boolean;
|
402
|
+
emit(event: "test:watch:drained"): boolean;
|
404
403
|
emit(event: string | symbol, ...args: any[]): boolean;
|
405
404
|
on(event: "test:coverage", listener: (data: TestCoverage) => void): this;
|
406
405
|
on(event: "test:complete", listener: (data: TestComplete) => void): this;
|
@@ -413,6 +412,7 @@ declare module "node:test" {
|
|
413
412
|
on(event: "test:start", listener: (data: TestStart) => void): this;
|
414
413
|
on(event: "test:stderr", listener: (data: TestStderr) => void): this;
|
415
414
|
on(event: "test:stdout", listener: (data: TestStdout) => void): this;
|
415
|
+
on(event: "test:watch:drained", listener: () => void): this;
|
416
416
|
on(event: string, listener: (...args: any[]) => void): this;
|
417
417
|
once(event: "test:coverage", listener: (data: TestCoverage) => void): this;
|
418
418
|
once(event: "test:complete", listener: (data: TestComplete) => void): this;
|
@@ -425,6 +425,7 @@ declare module "node:test" {
|
|
425
425
|
once(event: "test:start", listener: (data: TestStart) => void): this;
|
426
426
|
once(event: "test:stderr", listener: (data: TestStderr) => void): this;
|
427
427
|
once(event: "test:stdout", listener: (data: TestStdout) => void): this;
|
428
|
+
once(event: "test:watch:drained", listener: () => void): this;
|
428
429
|
once(event: string, listener: (...args: any[]) => void): this;
|
429
430
|
prependListener(event: "test:coverage", listener: (data: TestCoverage) => void): this;
|
430
431
|
prependListener(event: "test:complete", listener: (data: TestComplete) => void): this;
|
@@ -437,6 +438,7 @@ declare module "node:test" {
|
|
437
438
|
prependListener(event: "test:start", listener: (data: TestStart) => void): this;
|
438
439
|
prependListener(event: "test:stderr", listener: (data: TestStderr) => void): this;
|
439
440
|
prependListener(event: "test:stdout", listener: (data: TestStdout) => void): this;
|
441
|
+
prependListener(event: "test:watch:drained", listener: () => void): this;
|
440
442
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
441
443
|
prependOnceListener(event: "test:coverage", listener: (data: TestCoverage) => void): this;
|
442
444
|
prependOnceListener(event: "test:complete", listener: (data: TestComplete) => void): this;
|
@@ -449,6 +451,7 @@ declare module "node:test" {
|
|
449
451
|
prependOnceListener(event: "test:start", listener: (data: TestStart) => void): this;
|
450
452
|
prependOnceListener(event: "test:stderr", listener: (data: TestStderr) => void): this;
|
451
453
|
prependOnceListener(event: "test:stdout", listener: (data: TestStdout) => void): this;
|
454
|
+
prependOnceListener(event: "test:watch:drained", listener: () => void): this;
|
452
455
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
453
456
|
}
|
454
457
|
/**
|
@@ -460,32 +463,28 @@ declare module "node:test" {
|
|
460
463
|
class TestContext {
|
461
464
|
/**
|
462
465
|
* This function is used to create a hook running before subtest of the current test.
|
463
|
-
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
464
|
-
* the second argument. **Default:** A no-op function.
|
466
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
465
467
|
* @param options Configuration options for the hook.
|
466
468
|
* @since v20.1.0
|
467
469
|
*/
|
468
470
|
before: typeof before;
|
469
471
|
/**
|
470
472
|
* This function is used to create a hook running before each subtest of the current test.
|
471
|
-
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
472
|
-
* the second argument. **Default:** A no-op function.
|
473
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
473
474
|
* @param options Configuration options for the hook.
|
474
475
|
* @since v18.8.0
|
475
476
|
*/
|
476
477
|
beforeEach: typeof beforeEach;
|
477
478
|
/**
|
478
479
|
* This function is used to create a hook that runs after the current test finishes.
|
479
|
-
* @param
|
480
|
-
* the second argument. Default: A no-op function.
|
480
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
481
481
|
* @param options Configuration options for the hook.
|
482
482
|
* @since v18.13.0
|
483
483
|
*/
|
484
484
|
after: typeof after;
|
485
485
|
/**
|
486
486
|
* This function is used to create a hook running after each subtest of the current test.
|
487
|
-
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
488
|
-
* the second argument. **Default:** A no-op function.
|
487
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
489
488
|
* @param options Configuration options for the hook.
|
490
489
|
* @since v18.8.0
|
491
490
|
*/
|
@@ -573,11 +572,10 @@ declare module "node:test" {
|
|
573
572
|
* the same fashion as the top level {@link test} function.
|
574
573
|
* @since v18.0.0
|
575
574
|
* @param name The name of the test, which is displayed when reporting test results.
|
576
|
-
*
|
577
|
-
* @param options Configuration options for the test
|
578
|
-
* @param fn The function under test. This first argument to this function is a
|
579
|
-
*
|
580
|
-
* passed as the second argument. **Default:** A no-op function.
|
575
|
+
* Defaults to the `name` property of `fn`, or `'<anonymous>'` if `fn` does not have a name.
|
576
|
+
* @param options Configuration options for the test.
|
577
|
+
* @param fn The function under test. This first argument to this function is a {@link TestContext} object.
|
578
|
+
* If the test uses callbacks, the callback function is passed as the second argument.
|
581
579
|
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
582
580
|
*/
|
583
581
|
test: typeof test;
|
@@ -658,8 +656,8 @@ declare module "node:test" {
|
|
658
656
|
* });
|
659
657
|
* ```
|
660
658
|
* @since v18.8.0, v16.18.0
|
661
|
-
* @param
|
662
|
-
* @param options Configuration options for the hook.
|
659
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
660
|
+
* @param options Configuration options for the hook.
|
663
661
|
*/
|
664
662
|
function before(fn?: HookFn, options?: HookOptions): void;
|
665
663
|
/**
|
@@ -674,8 +672,8 @@ declare module "node:test" {
|
|
674
672
|
* });
|
675
673
|
* ```
|
676
674
|
* @since v18.8.0, v16.18.0
|
677
|
-
* @param
|
678
|
-
* @param options Configuration options for the hook.
|
675
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
676
|
+
* @param options Configuration options for the hook.
|
679
677
|
*/
|
680
678
|
function after(fn?: HookFn, options?: HookOptions): void;
|
681
679
|
/**
|
@@ -690,8 +688,8 @@ declare module "node:test" {
|
|
690
688
|
* });
|
691
689
|
* ```
|
692
690
|
* @since v18.8.0, v16.18.0
|
693
|
-
* @param
|
694
|
-
* @param options Configuration options for the hook.
|
691
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
692
|
+
* @param options Configuration options for the hook.
|
695
693
|
*/
|
696
694
|
function beforeEach(fn?: HookFn, options?: HookOptions): void;
|
697
695
|
/**
|
@@ -707,8 +705,8 @@ declare module "node:test" {
|
|
707
705
|
* });
|
708
706
|
* ```
|
709
707
|
* @since v18.8.0, v16.18.0
|
710
|
-
* @param
|
711
|
-
* @param options Configuration options for the hook.
|
708
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
709
|
+
* @param options Configuration options for the hook.
|
712
710
|
*/
|
713
711
|
function afterEach(fn?: HookFn, options?: HookOptions): void;
|
714
712
|
/**
|
@@ -798,10 +796,10 @@ declare module "node:test" {
|
|
798
796
|
* });
|
799
797
|
* ```
|
800
798
|
* @since v19.1.0, v18.13.0
|
801
|
-
* @param
|
799
|
+
* @param original An optional function to create a mock on.
|
802
800
|
* @param implementation An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and
|
803
801
|
* then restore the behavior of `original`.
|
804
|
-
* @param options Optional configuration options for the mock function.
|
802
|
+
* @param options Optional configuration options for the mock function.
|
805
803
|
* @return The mocked function. The mocked function contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the
|
806
804
|
* behavior of the mocked function.
|
807
805
|
*/
|
@@ -843,7 +841,7 @@ declare module "node:test" {
|
|
843
841
|
* @param object The object whose method is being mocked.
|
844
842
|
* @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.
|
845
843
|
* @param implementation An optional function used as the mock implementation for `object[methodName]`.
|
846
|
-
* @param options Optional configuration options for the mock method.
|
844
|
+
* @param options Optional configuration options for the mock method.
|
847
845
|
* @return The mocked method. The mocked method contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the
|
848
846
|
* behavior of the mocked method.
|
849
847
|
*/
|
@@ -923,6 +921,7 @@ declare module "node:test" {
|
|
923
921
|
implementation?: Implementation,
|
924
922
|
options?: MockFunctionOptions,
|
925
923
|
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
|
924
|
+
|
926
925
|
/**
|
927
926
|
* This function restores the default behavior of all mocks that were previously
|
928
927
|
* 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
|
@@ -941,6 +940,7 @@ declare module "node:test" {
|
|
941
940
|
* @since v19.1.0, v18.13.0
|
942
941
|
*/
|
943
942
|
restoreAll(): void;
|
943
|
+
|
944
944
|
timers: MockTimers;
|
945
945
|
}
|
946
946
|
const mock: MockTracker;
|
@@ -1081,11 +1081,11 @@ declare module "node:test" {
|
|
1081
1081
|
*/
|
1082
1082
|
restore(): void;
|
1083
1083
|
}
|
1084
|
-
type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date";
|
1085
1084
|
|
1085
|
+
type Timer = "setInterval" | "setTimeout" | "setImmediate" | "Date";
|
1086
1086
|
interface MockTimersOptions {
|
1087
1087
|
apis: Timer[];
|
1088
|
-
now?: number | Date;
|
1088
|
+
now?: number | Date | undefined;
|
1089
1089
|
}
|
1090
1090
|
/**
|
1091
1091
|
* Mocking timers is a technique commonly used in software testing to simulate and
|
@@ -1324,6 +1324,9 @@ declare module "node:test" {
|
|
1324
1324
|
};
|
1325
1325
|
}
|
1326
1326
|
|
1327
|
+
interface TestError extends Error {
|
1328
|
+
cause: Error;
|
1329
|
+
}
|
1327
1330
|
interface TestLocationInfo {
|
1328
1331
|
/**
|
1329
1332
|
* The column number where the test is defined, or
|
@@ -1355,7 +1358,7 @@ interface TestCoverage {
|
|
1355
1358
|
*/
|
1356
1359
|
summary: {
|
1357
1360
|
/**
|
1358
|
-
* An array of coverage reports for individual files.
|
1361
|
+
* An array of coverage reports for individual files.
|
1359
1362
|
*/
|
1360
1363
|
files: Array<{
|
1361
1364
|
/**
|
@@ -1415,6 +1418,19 @@ interface TestCoverage {
|
|
1415
1418
|
*/
|
1416
1419
|
count: number;
|
1417
1420
|
}>;
|
1421
|
+
/**
|
1422
|
+
* An array of branches representing branch coverage.
|
1423
|
+
*/
|
1424
|
+
branches: Array<{
|
1425
|
+
/**
|
1426
|
+
* The line number where the branch is defined.
|
1427
|
+
*/
|
1428
|
+
line: number;
|
1429
|
+
/**
|
1430
|
+
* The number of times the branch was taken.
|
1431
|
+
*/
|
1432
|
+
count: number;
|
1433
|
+
}>;
|
1418
1434
|
/**
|
1419
1435
|
* An array of lines representing line numbers and the number of times they were covered.
|
1420
1436
|
*/
|
@@ -1498,7 +1514,7 @@ interface TestComplete extends TestLocationInfo {
|
|
1498
1514
|
/**
|
1499
1515
|
* An error wrapping the error thrown by the test if it did not pass.
|
1500
1516
|
*/
|
1501
|
-
error
|
1517
|
+
error?: TestError;
|
1502
1518
|
/**
|
1503
1519
|
* The type of the test, used to denote whether this is a suite.
|
1504
1520
|
*/
|
@@ -1555,9 +1571,9 @@ interface TestFail extends TestLocationInfo {
|
|
1555
1571
|
*/
|
1556
1572
|
duration_ms: number;
|
1557
1573
|
/**
|
1558
|
-
* An error wrapping the error thrown by the test
|
1574
|
+
* An error wrapping the error thrown by the test.
|
1559
1575
|
*/
|
1560
|
-
error:
|
1576
|
+
error: TestError;
|
1561
1577
|
/**
|
1562
1578
|
* The type of the test, used to denote whether this is a suite.
|
1563
1579
|
* @since v20.0.0, v19.9.0, v18.17.0
|
@@ -1641,13 +1657,21 @@ interface TestStart extends TestLocationInfo {
|
|
1641
1657
|
*/
|
1642
1658
|
nesting: number;
|
1643
1659
|
}
|
1644
|
-
interface TestStderr
|
1660
|
+
interface TestStderr {
|
1661
|
+
/**
|
1662
|
+
* The path of the test file.
|
1663
|
+
*/
|
1664
|
+
file: string;
|
1645
1665
|
/**
|
1646
1666
|
* The message written to `stderr`.
|
1647
1667
|
*/
|
1648
1668
|
message: string;
|
1649
1669
|
}
|
1650
|
-
interface TestStdout
|
1670
|
+
interface TestStdout {
|
1671
|
+
/**
|
1672
|
+
* The path of the test file.
|
1673
|
+
*/
|
1674
|
+
file: string;
|
1651
1675
|
/**
|
1652
1676
|
* The message written to `stdout`.
|
1653
1677
|
*/
|
@@ -1686,7 +1710,7 @@ declare module "node:test/reporters" {
|
|
1686
1710
|
| { type: "test:start"; data: TestStart }
|
1687
1711
|
| { type: "test:stderr"; data: TestStderr }
|
1688
1712
|
| { type: "test:stdout"; data: TestStdout }
|
1689
|
-
| { type: "test:watch:drained" };
|
1713
|
+
| { type: "test:watch:drained"; data: undefined };
|
1690
1714
|
type TestEventGenerator = AsyncGenerator<TestEvent, void>;
|
1691
1715
|
|
1692
1716
|
/**
|
node/url.d.ts
CHANGED
@@ -46,6 +46,22 @@ declare module "url" {
|
|
46
46
|
interface UrlWithStringQuery extends Url {
|
47
47
|
query: string | null;
|
48
48
|
}
|
49
|
+
interface FileUrlToPathOptions {
|
50
|
+
/**
|
51
|
+
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
|
52
|
+
* @default undefined
|
53
|
+
* @since v22.1.0
|
54
|
+
*/
|
55
|
+
windows?: boolean | undefined;
|
56
|
+
}
|
57
|
+
interface PathToFileUrlOptions {
|
58
|
+
/**
|
59
|
+
* `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
|
60
|
+
* @default undefined
|
61
|
+
* @since v22.1.0
|
62
|
+
*/
|
63
|
+
windows?: boolean | undefined;
|
64
|
+
}
|
49
65
|
/**
|
50
66
|
* The `url.parse()` method takes a URL string, parses it, and returns a URL
|
51
67
|
* object.
|
@@ -298,7 +314,7 @@ declare module "url" {
|
|
298
314
|
* @param url The file URL string or URL object to convert to a path.
|
299
315
|
* @return The fully-resolved platform-specific Node.js file path.
|
300
316
|
*/
|
301
|
-
function fileURLToPath(url: string | URL): string;
|
317
|
+
function fileURLToPath(url: string | URL, options?: FileUrlToPathOptions): string;
|
302
318
|
/**
|
303
319
|
* This function ensures that `path` is resolved absolutely, and that the URL
|
304
320
|
* control characters are correctly encoded when converting into a File URL.
|
@@ -316,7 +332,7 @@ declare module "url" {
|
|
316
332
|
* @param path The path to convert to a File URL.
|
317
333
|
* @return The file URL object.
|
318
334
|
*/
|
319
|
-
function pathToFileURL(path: string): URL;
|
335
|
+
function pathToFileURL(path: string, options?: PathToFileUrlOptions): URL;
|
320
336
|
/**
|
321
337
|
* This utility function converts a URL object into an ordinary options object as
|
322
338
|
* expected by the `http.request()` and `https.request()` APIs.
|
@@ -429,6 +445,15 @@ declare module "url" {
|
|
429
445
|
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
430
446
|
*/
|
431
447
|
static canParse(input: string, base?: string): boolean;
|
448
|
+
/**
|
449
|
+
* Parses a string as a URL. If `base` is provided, it will be used as the base URL for the purpose of resolving non-absolute `input` URLs.
|
450
|
+
* Returns `null` if `input` is not a valid.
|
451
|
+
* @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is
|
452
|
+
* `converted to a string` first.
|
453
|
+
* @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first.
|
454
|
+
* @since v22.1.0
|
455
|
+
*/
|
456
|
+
static parse(input: string, base?: string): URL | null;
|
432
457
|
constructor(input: string | { toString: () => string }, base?: string | URL);
|
433
458
|
/**
|
434
459
|
* Gets and sets the fragment portion of the URL.
|