@chainlink/external-adapter-framework 2.8.0 → 2.9.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.
- package/README.md +1 -1
- package/adapter/basic.js +21 -4
- package/adapter/basic.js.map +1 -1
- package/adapter/endpoint.js +13 -0
- package/adapter/endpoint.js.map +1 -1
- package/adapter/por.js +6 -6
- package/adapter/por.js.map +1 -1
- package/adapter/price.js +1 -0
- package/adapter/price.js.map +1 -1
- package/cache/local.js +5 -1
- package/cache/local.js.map +1 -1
- package/cache/redis.js +3 -1
- package/cache/redis.js.map +1 -1
- package/cache/response.js +5 -0
- package/cache/response.js.map +1 -1
- package/config/index.js +9 -6
- package/config/index.js.map +1 -1
- package/generator-adapter/node_modules/.yarn-integrity +4 -4
- package/generator-adapter/node_modules/@types/node/README.md +3 -3
- package/generator-adapter/node_modules/@types/node/assert/strict.d.ts +105 -2
- package/generator-adapter/node_modules/@types/node/assert.d.ts +162 -101
- package/generator-adapter/node_modules/@types/node/async_hooks.d.ts +25 -5
- package/generator-adapter/node_modules/@types/node/buffer.buffer.d.ts +9 -0
- package/generator-adapter/node_modules/@types/node/buffer.d.ts +9 -5
- package/generator-adapter/node_modules/@types/node/child_process.d.ts +67 -44
- package/generator-adapter/node_modules/@types/node/cluster.d.ts +19 -20
- package/generator-adapter/node_modules/@types/node/compatibility/iterators.d.ts +1 -0
- package/generator-adapter/node_modules/@types/node/console.d.ts +19 -18
- package/generator-adapter/node_modules/@types/node/crypto.d.ts +1247 -355
- package/generator-adapter/node_modules/@types/node/dgram.d.ts +10 -9
- package/generator-adapter/node_modules/@types/node/diagnostics_channel.d.ts +1 -3
- package/generator-adapter/node_modules/@types/node/dns/promises.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/dns.d.ts +23 -18
- package/generator-adapter/node_modules/@types/node/domain.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/events.d.ts +81 -35
- package/generator-adapter/node_modules/@types/node/fs/promises.d.ts +62 -22
- package/generator-adapter/node_modules/@types/node/fs.d.ts +364 -98
- package/generator-adapter/node_modules/@types/node/globals.d.ts +4 -4
- package/generator-adapter/node_modules/@types/node/globals.typedarray.d.ts +20 -0
- package/generator-adapter/node_modules/@types/node/http.d.ts +120 -32
- package/generator-adapter/node_modules/@types/node/http2.d.ts +185 -65
- package/generator-adapter/node_modules/@types/node/https.d.ts +92 -63
- package/generator-adapter/node_modules/@types/node/index.d.ts +10 -5
- package/generator-adapter/node_modules/@types/node/inspector.d.ts +277 -0
- package/generator-adapter/node_modules/@types/node/inspector.generated.d.ts +908 -886
- package/generator-adapter/node_modules/@types/node/module.d.ts +21 -18
- package/generator-adapter/node_modules/@types/node/net.d.ts +35 -16
- package/generator-adapter/node_modules/@types/node/os.d.ts +22 -10
- package/generator-adapter/node_modules/@types/node/package.json +13 -3
- package/generator-adapter/node_modules/@types/node/path.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/perf_hooks.d.ts +28 -16
- package/generator-adapter/node_modules/@types/node/process.d.ts +30 -30
- package/generator-adapter/node_modules/@types/node/punycode.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/querystring.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/readline/promises.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/readline.d.ts +13 -13
- package/generator-adapter/node_modules/@types/node/repl.d.ts +23 -13
- package/generator-adapter/node_modules/@types/node/sea.d.ts +10 -1
- package/generator-adapter/node_modules/@types/node/sqlite.d.ts +245 -23
- package/generator-adapter/node_modules/@types/node/stream/consumers.d.ts +2 -2
- package/generator-adapter/node_modules/@types/node/stream/web.d.ts +6 -55
- package/generator-adapter/node_modules/@types/node/stream.d.ts +63 -37
- package/generator-adapter/node_modules/@types/node/string_decoder.d.ts +3 -3
- package/generator-adapter/node_modules/@types/node/test.d.ts +196 -40
- package/generator-adapter/node_modules/@types/node/timers/promises.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/timers.d.ts +1 -3
- package/generator-adapter/node_modules/@types/node/tls.d.ts +124 -114
- package/generator-adapter/node_modules/@types/node/trace_events.d.ts +6 -6
- package/generator-adapter/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +10 -2
- package/generator-adapter/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/generator-adapter/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +17 -0
- package/generator-adapter/node_modules/@types/node/ts5.6/index.d.ts +12 -5
- package/generator-adapter/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/generator-adapter/node_modules/@types/node/ts5.7/index.d.ts +103 -0
- package/generator-adapter/node_modules/@types/node/tty.d.ts +1 -1
- package/generator-adapter/node_modules/@types/node/url.d.ts +109 -33
- package/generator-adapter/node_modules/@types/node/util.d.ts +31 -305
- package/generator-adapter/node_modules/@types/node/v8.d.ts +41 -8
- package/generator-adapter/node_modules/@types/node/vm.d.ts +258 -107
- package/generator-adapter/node_modules/@types/node/wasi.d.ts +23 -2
- package/generator-adapter/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
- package/generator-adapter/node_modules/@types/node/web-globals/events.d.ts +3 -0
- package/generator-adapter/node_modules/@types/node/web-globals/fetch.d.ts +4 -0
- package/generator-adapter/node_modules/@types/node/web-globals/navigator.d.ts +3 -0
- package/generator-adapter/node_modules/@types/node/web-globals/streams.d.ts +22 -0
- package/generator-adapter/node_modules/@types/node/worker_threads.d.ts +142 -51
- package/generator-adapter/node_modules/@types/node/zlib.d.ts +36 -31
- package/generator-adapter/node_modules/undici-types/agent.d.ts +12 -11
- package/generator-adapter/node_modules/undici-types/api.d.ts +24 -24
- package/generator-adapter/node_modules/undici-types/balanced-pool.d.ts +11 -11
- package/generator-adapter/node_modules/undici-types/cache-interceptor.d.ts +172 -0
- package/generator-adapter/node_modules/undici-types/client-stats.d.ts +15 -0
- package/generator-adapter/node_modules/undici-types/client.d.ts +18 -18
- package/generator-adapter/node_modules/undici-types/cookies.d.ts +2 -0
- package/generator-adapter/node_modules/undici-types/diagnostics-channel.d.ts +18 -10
- package/generator-adapter/node_modules/undici-types/dispatcher.d.ts +119 -99
- package/generator-adapter/node_modules/undici-types/env-http-proxy-agent.d.ts +4 -3
- package/generator-adapter/node_modules/undici-types/errors.d.ts +66 -54
- package/generator-adapter/node_modules/undici-types/eventsource.d.ts +9 -4
- package/generator-adapter/node_modules/undici-types/fetch.d.ts +18 -16
- package/generator-adapter/node_modules/undici-types/formdata.d.ts +7 -7
- package/generator-adapter/node_modules/undici-types/global-dispatcher.d.ts +4 -4
- package/generator-adapter/node_modules/undici-types/global-origin.d.ts +5 -5
- package/generator-adapter/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/generator-adapter/node_modules/undici-types/handlers.d.ts +8 -8
- package/generator-adapter/node_modules/undici-types/header.d.ts +157 -1
- package/generator-adapter/node_modules/undici-types/index.d.ts +56 -47
- package/generator-adapter/node_modules/undici-types/interceptors.d.ts +30 -8
- package/generator-adapter/node_modules/undici-types/mock-agent.d.ts +36 -18
- package/generator-adapter/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/generator-adapter/node_modules/undici-types/mock-client.d.ts +6 -4
- package/generator-adapter/node_modules/undici-types/mock-errors.d.ts +3 -3
- package/generator-adapter/node_modules/undici-types/mock-interceptor.d.ts +21 -20
- package/generator-adapter/node_modules/undici-types/mock-pool.d.ts +6 -4
- package/generator-adapter/node_modules/undici-types/package.json +1 -1
- package/generator-adapter/node_modules/undici-types/patch.d.ts +0 -4
- package/generator-adapter/node_modules/undici-types/pool-stats.d.ts +8 -8
- package/generator-adapter/node_modules/undici-types/pool.d.ts +14 -12
- package/generator-adapter/node_modules/undici-types/proxy-agent.d.ts +5 -4
- package/generator-adapter/node_modules/undici-types/readable.d.ts +18 -15
- package/generator-adapter/node_modules/undici-types/retry-agent.d.ts +1 -1
- package/generator-adapter/node_modules/undici-types/retry-handler.d.ts +19 -10
- package/generator-adapter/node_modules/undici-types/snapshot-agent.d.ts +109 -0
- package/generator-adapter/node_modules/undici-types/util.d.ts +3 -3
- package/generator-adapter/node_modules/undici-types/utility.d.ts +7 -0
- package/generator-adapter/node_modules/undici-types/webidl.d.ts +142 -29
- package/generator-adapter/node_modules/undici-types/websocket.d.ts +38 -2
- package/generator-adapter/package.json +1 -1
- package/metrics/index.js +3 -0
- package/metrics/index.js.map +1 -1
- package/package.json +8 -8
- package/rate-limiting/burst.js +6 -6
- package/rate-limiting/burst.js.map +1 -1
- package/rate-limiting/fixed-interval.js +2 -3
- package/rate-limiting/fixed-interval.js.map +1 -1
- package/transports/abstract/streaming.js +7 -10
- package/transports/abstract/streaming.js.map +1 -1
- package/transports/abstract/subscription.js +4 -0
- package/transports/abstract/subscription.js.map +1 -1
- package/transports/http.js +5 -3
- package/transports/http.js.map +1 -1
- package/transports/index.js +1 -3
- package/transports/index.js.map +1 -1
- package/transports/sse.js +6 -2
- package/transports/sse.js.map +1 -1
- package/transports/websocket.d.ts +9 -1
- package/transports/websocket.js +25 -13
- package/transports/websocket.js.map +1 -1
- package/util/censor/censor-list.js +1 -1
- package/util/censor/censor-list.js.map +1 -1
- package/util/group-runner.js +3 -2
- package/util/group-runner.js.map +1 -1
- package/util/index.js +8 -1
- package/util/index.js.map +1 -1
- package/util/logger.js +8 -1
- package/util/logger.js.map +1 -1
- package/util/requester.js +11 -3
- package/util/requester.js.map +1 -1
- package/util/subscription-set/expiring-sorted-set.js +3 -0
- package/util/subscription-set/expiring-sorted-set.js.map +1 -1
- package/util/subscription-set/redis-sorted-set.js +3 -0
- package/util/subscription-set/redis-sorted-set.js.map +1 -1
- package/util/subscription-set/subscription-set.js +5 -0
- package/util/subscription-set/subscription-set.js.map +1 -1
- package/util/testing-utils.js +13 -6
- package/util/testing-utils.js.map +1 -1
- package/validation/error.js +13 -0
- package/validation/error.js.map +1 -1
- package/validation/input-params.js +14 -0
- package/validation/input-params.js.map +1 -1
- package/generator-adapter/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
- package/generator-adapter/node_modules/@types/node/compatibility/index.d.ts +0 -9
- package/generator-adapter/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
- package/generator-adapter/node_modules/undici-types/file.d.ts +0 -39
- package/generator-adapter/node_modules/undici-types/filereader.d.ts +0 -54
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* A stream is an abstract interface for working with streaming data in Node.js.
|
|
3
3
|
* The `node:stream` module provides an API for implementing the stream interface.
|
|
4
4
|
*
|
|
5
|
-
* There are many stream objects provided by Node.js. For instance, a [request to an HTTP server](https://nodejs.org/docs/latest-
|
|
6
|
-
* and [`process.stdout`](https://nodejs.org/docs/latest-
|
|
5
|
+
* There are many stream objects provided by Node.js. For instance, a [request to an HTTP server](https://nodejs.org/docs/latest-v24.x/api/http.html#class-httpincomingmessage)
|
|
6
|
+
* and [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) are both stream instances.
|
|
7
7
|
*
|
|
8
|
-
* Streams can be readable, writable, or both. All streams are instances of [`EventEmitter`](https://nodejs.org/docs/latest-
|
|
8
|
+
* Streams can be readable, writable, or both. All streams are instances of [`EventEmitter`](https://nodejs.org/docs/latest-v24.x/api/events.html#class-eventemitter).
|
|
9
9
|
*
|
|
10
10
|
* To access the `node:stream` module:
|
|
11
11
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* The `node:stream` module is useful for creating new types of stream instances.
|
|
17
17
|
* It is usually not necessary to use the `node:stream` module to consume streams.
|
|
18
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
18
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/stream.js)
|
|
19
19
|
*/
|
|
20
20
|
declare module "stream" {
|
|
21
21
|
import { Abortable, EventEmitter } from "node:events";
|
|
@@ -45,22 +45,22 @@ declare module "stream" {
|
|
|
45
45
|
emitClose?: boolean | undefined;
|
|
46
46
|
highWaterMark?: number | undefined;
|
|
47
47
|
objectMode?: boolean | undefined;
|
|
48
|
-
construct
|
|
49
|
-
destroy
|
|
48
|
+
construct?: ((this: T, callback: (error?: Error | null) => void) => void) | undefined;
|
|
49
|
+
destroy?: ((this: T, error: Error | null, callback: (error?: Error | null) => void) => void) | undefined;
|
|
50
50
|
autoDestroy?: boolean | undefined;
|
|
51
51
|
}
|
|
52
52
|
interface ReadableOptions<T extends Readable = Readable> extends StreamOptions<T> {
|
|
53
53
|
encoding?: BufferEncoding | undefined;
|
|
54
|
-
read
|
|
54
|
+
read?: ((this: T, size: number) => void) | undefined;
|
|
55
55
|
}
|
|
56
56
|
interface ArrayOptions {
|
|
57
57
|
/**
|
|
58
58
|
* The maximum concurrent invocations of `fn` to call on the stream at once.
|
|
59
59
|
* @default 1
|
|
60
60
|
*/
|
|
61
|
-
concurrency?: number;
|
|
61
|
+
concurrency?: number | undefined;
|
|
62
62
|
/** Allows destroying the stream if the signal is aborted. */
|
|
63
|
-
signal?: AbortSignal;
|
|
63
|
+
signal?: AbortSignal | undefined;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* @since v0.9.4
|
|
@@ -118,13 +118,13 @@ declare module "stream" {
|
|
|
118
118
|
*/
|
|
119
119
|
readonly readableEncoding: BufferEncoding | null;
|
|
120
120
|
/**
|
|
121
|
-
* Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-
|
|
121
|
+
* Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v24.x/api/stream.html#event-end) event is emitted.
|
|
122
122
|
* @since v12.9.0
|
|
123
123
|
*/
|
|
124
124
|
readonly readableEnded: boolean;
|
|
125
125
|
/**
|
|
126
126
|
* This property reflects the current state of a `Readable` stream as described
|
|
127
|
-
* in the [Three states](https://nodejs.org/docs/latest-
|
|
127
|
+
* in the [Three states](https://nodejs.org/docs/latest-v24.x/api/stream.html#three-states) section.
|
|
128
128
|
* @since v9.4.0
|
|
129
129
|
*/
|
|
130
130
|
readonly readableFlowing: boolean | null;
|
|
@@ -615,6 +615,17 @@ declare module "stream" {
|
|
|
615
615
|
* @param error Error which will be passed as payload in `'error'` event
|
|
616
616
|
*/
|
|
617
617
|
destroy(error?: Error): this;
|
|
618
|
+
/**
|
|
619
|
+
* @returns `AsyncIterator` to fully consume the stream.
|
|
620
|
+
* @since v10.0.0
|
|
621
|
+
*/
|
|
622
|
+
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
|
|
623
|
+
/**
|
|
624
|
+
* Calls `readable.destroy()` with an `AbortError` and returns
|
|
625
|
+
* a promise that fulfills when the stream is finished.
|
|
626
|
+
* @since v20.4.0
|
|
627
|
+
*/
|
|
628
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
618
629
|
/**
|
|
619
630
|
* Event emitter
|
|
620
631
|
* The defined events on documents including:
|
|
@@ -682,31 +693,29 @@ declare module "stream" {
|
|
|
682
693
|
removeListener(event: "readable", listener: () => void): this;
|
|
683
694
|
removeListener(event: "resume", listener: () => void): this;
|
|
684
695
|
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
685
|
-
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
|
|
686
|
-
/**
|
|
687
|
-
* Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished.
|
|
688
|
-
* @since v20.4.0
|
|
689
|
-
*/
|
|
690
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
691
696
|
}
|
|
692
697
|
interface WritableOptions<T extends Writable = Writable> extends StreamOptions<T> {
|
|
693
698
|
decodeStrings?: boolean | undefined;
|
|
694
699
|
defaultEncoding?: BufferEncoding | undefined;
|
|
695
|
-
write
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
700
|
+
write?:
|
|
701
|
+
| ((
|
|
702
|
+
this: T,
|
|
703
|
+
chunk: any,
|
|
704
|
+
encoding: BufferEncoding,
|
|
705
|
+
callback: (error?: Error | null) => void,
|
|
706
|
+
) => void)
|
|
707
|
+
| undefined;
|
|
708
|
+
writev?:
|
|
709
|
+
| ((
|
|
710
|
+
this: T,
|
|
711
|
+
chunks: Array<{
|
|
712
|
+
chunk: any;
|
|
713
|
+
encoding: BufferEncoding;
|
|
714
|
+
}>,
|
|
715
|
+
callback: (error?: Error | null) => void,
|
|
716
|
+
) => void)
|
|
717
|
+
| undefined;
|
|
718
|
+
final?: ((this: T, callback: (error?: Error | null) => void) => void) | undefined;
|
|
710
719
|
}
|
|
711
720
|
/**
|
|
712
721
|
* @since v0.9.4
|
|
@@ -957,6 +966,12 @@ declare module "stream" {
|
|
|
957
966
|
* @param error Optional, an error to emit with `'error'` event.
|
|
958
967
|
*/
|
|
959
968
|
destroy(error?: Error): this;
|
|
969
|
+
/**
|
|
970
|
+
* Calls `writable.destroy()` with an `AbortError` and returns
|
|
971
|
+
* a promise that fulfills when the stream is finished.
|
|
972
|
+
* @since v22.4.0, v20.16.0
|
|
973
|
+
*/
|
|
974
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
960
975
|
/**
|
|
961
976
|
* Event emitter
|
|
962
977
|
* The defined events on documents including:
|
|
@@ -1224,8 +1239,10 @@ declare module "stream" {
|
|
|
1224
1239
|
function duplexPair(options?: DuplexOptions): [Duplex, Duplex];
|
|
1225
1240
|
type TransformCallback = (error?: Error | null, data?: any) => void;
|
|
1226
1241
|
interface TransformOptions<T extends Transform = Transform> extends DuplexOptions<T> {
|
|
1227
|
-
transform
|
|
1228
|
-
|
|
1242
|
+
transform?:
|
|
1243
|
+
| ((this: T, chunk: any, encoding: BufferEncoding, callback: TransformCallback) => void)
|
|
1244
|
+
| undefined;
|
|
1245
|
+
flush?: ((this: T, callback: TransformCallback) => void) | undefined;
|
|
1229
1246
|
}
|
|
1230
1247
|
/**
|
|
1231
1248
|
* Transform streams are `Duplex` streams where the output is in some way
|
|
@@ -1371,7 +1388,7 @@ declare module "stream" {
|
|
|
1371
1388
|
* Especially useful in error handling scenarios where a stream is destroyed
|
|
1372
1389
|
* prematurely (like an aborted HTTP request), and will not emit `'end'` or `'finish'`.
|
|
1373
1390
|
*
|
|
1374
|
-
* The `finished` API provides [`promise version`](https://nodejs.org/docs/latest-
|
|
1391
|
+
* The `finished` API provides [`promise version`](https://nodejs.org/docs/latest-v24.x/api/stream.html#streamfinishedstream-options).
|
|
1375
1392
|
*
|
|
1376
1393
|
* `stream.finished()` leaves dangling event listeners (in particular `'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
|
|
1377
1394
|
* invoked. The reason for this is so that unexpected `'error'` events (due to
|
|
@@ -1459,7 +1476,7 @@ declare module "stream" {
|
|
|
1459
1476
|
* );
|
|
1460
1477
|
* ```
|
|
1461
1478
|
*
|
|
1462
|
-
* The `pipeline` API provides a [`promise version`](https://nodejs.org/docs/latest-
|
|
1479
|
+
* The `pipeline` API provides a [`promise version`](https://nodejs.org/docs/latest-v24.x/api/stream.html#streampipelinesource-transforms-destination-options).
|
|
1463
1480
|
*
|
|
1464
1481
|
* `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
|
|
1465
1482
|
*
|
|
@@ -1632,12 +1649,14 @@ declare module "stream" {
|
|
|
1632
1649
|
...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
|
|
1633
1650
|
): Promise<void>;
|
|
1634
1651
|
}
|
|
1652
|
+
// TODO: this interface never existed; remove in next major
|
|
1635
1653
|
interface Pipe {
|
|
1636
1654
|
close(): void;
|
|
1637
1655
|
hasRef(): boolean;
|
|
1638
1656
|
ref(): void;
|
|
1639
1657
|
unref(): void;
|
|
1640
1658
|
}
|
|
1659
|
+
// TODO: these should all take webstream arguments
|
|
1641
1660
|
/**
|
|
1642
1661
|
* Returns whether the stream has encountered an error.
|
|
1643
1662
|
* @since v17.3.0, v16.14.0
|
|
@@ -1646,8 +1665,15 @@ declare module "stream" {
|
|
|
1646
1665
|
/**
|
|
1647
1666
|
* Returns whether the stream is readable.
|
|
1648
1667
|
* @since v17.4.0, v16.14.0
|
|
1668
|
+
* @returns Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`.
|
|
1669
|
+
*/
|
|
1670
|
+
function isReadable(stream: Readable | NodeJS.ReadableStream): boolean | null;
|
|
1671
|
+
/**
|
|
1672
|
+
* Returns whether the stream is writable.
|
|
1673
|
+
* @since v20.0.0
|
|
1674
|
+
* @returns Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`.
|
|
1649
1675
|
*/
|
|
1650
|
-
function
|
|
1676
|
+
function isWritable(stream: Writable | NodeJS.WritableStream): boolean | null;
|
|
1651
1677
|
}
|
|
1652
1678
|
export = Stream;
|
|
1653
1679
|
}
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* decoder.write(Buffer.from([0x82]));
|
|
37
37
|
* console.log(decoder.end(Buffer.from([0xAC]))); // Prints: €
|
|
38
38
|
* ```
|
|
39
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
39
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/string_decoder.js)
|
|
40
40
|
*/
|
|
41
41
|
declare module "string_decoder" {
|
|
42
42
|
class StringDecoder {
|
|
@@ -48,7 +48,7 @@ declare module "string_decoder" {
|
|
|
48
48
|
* @since v0.1.99
|
|
49
49
|
* @param buffer The bytes to decode.
|
|
50
50
|
*/
|
|
51
|
-
write(buffer: string |
|
|
51
|
+
write(buffer: string | NodeJS.ArrayBufferView): string;
|
|
52
52
|
/**
|
|
53
53
|
* Returns any remaining input stored in the internal buffer as a string. Bytes
|
|
54
54
|
* representing incomplete UTF-8 and UTF-16 characters will be replaced with
|
|
@@ -59,7 +59,7 @@ declare module "string_decoder" {
|
|
|
59
59
|
* @since v0.9.3
|
|
60
60
|
* @param buffer The bytes to decode.
|
|
61
61
|
*/
|
|
62
|
-
end(buffer?: string |
|
|
62
|
+
end(buffer?: string | NodeJS.ArrayBufferView): string;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
declare module "node:string_decoder" {
|
|
@@ -76,9 +76,10 @@
|
|
|
76
76
|
*
|
|
77
77
|
* If any tests fail, the process exit code is set to `1`.
|
|
78
78
|
* @since v18.0.0, v16.17.0
|
|
79
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
79
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/test.js)
|
|
80
80
|
*/
|
|
81
81
|
declare module "node:test" {
|
|
82
|
+
import { AssertMethodNames } from "node:assert";
|
|
82
83
|
import { Readable } from "node:stream";
|
|
83
84
|
import TestFn = test.TestFn;
|
|
84
85
|
import TestOptions = test.TestOptions;
|
|
@@ -239,9 +240,17 @@ declare module "node:test" {
|
|
|
239
240
|
* @default false
|
|
240
241
|
*/
|
|
241
242
|
concurrency?: number | boolean | undefined;
|
|
243
|
+
/**
|
|
244
|
+
* Specifies the current working directory to be used by the test runner.
|
|
245
|
+
* Serves as the base path for resolving files according to the
|
|
246
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v24.x/api/test.html#test-runner-execution-model).
|
|
247
|
+
* @since v23.0.0
|
|
248
|
+
* @default process.cwd()
|
|
249
|
+
*/
|
|
250
|
+
cwd?: string | undefined;
|
|
242
251
|
/**
|
|
243
252
|
* An array containing the list of files to run. If omitted, files are run according to the
|
|
244
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
253
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v24.x/api/test.html#test-runner-execution-model).
|
|
245
254
|
*/
|
|
246
255
|
files?: readonly string[] | undefined;
|
|
247
256
|
/**
|
|
@@ -254,7 +263,7 @@ declare module "node:test" {
|
|
|
254
263
|
/**
|
|
255
264
|
* An array containing the list of glob patterns to match test files.
|
|
256
265
|
* This option cannot be used together with `files`. If omitted, files are run according to the
|
|
257
|
-
* [test runner execution model](https://nodejs.org/docs/latest-
|
|
266
|
+
* [test runner execution model](https://nodejs.org/docs/latest-v24.x/api/test.html#test-runner-execution-model).
|
|
258
267
|
* @since v22.6.0
|
|
259
268
|
*/
|
|
260
269
|
globPatterns?: readonly string[] | undefined;
|
|
@@ -335,7 +344,14 @@ declare module "node:test" {
|
|
|
335
344
|
*/
|
|
336
345
|
shard?: TestShard | undefined;
|
|
337
346
|
/**
|
|
338
|
-
*
|
|
347
|
+
* A file path where the test runner will
|
|
348
|
+
* store the state of the tests to allow rerunning only the failed tests on a next run.
|
|
349
|
+
* @since v24.7.0
|
|
350
|
+
* @default undefined
|
|
351
|
+
*/
|
|
352
|
+
rerunFailuresFilePath?: string | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* enable [code coverage](https://nodejs.org/docs/latest-v24.x/api/test.html#collecting-code-coverage) collection.
|
|
339
355
|
* @since v22.10.0
|
|
340
356
|
* @default false
|
|
341
357
|
*/
|
|
@@ -402,6 +418,7 @@ declare module "node:test" {
|
|
|
402
418
|
addListener(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
403
419
|
addListener(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
404
420
|
addListener(event: "test:watch:drained", listener: () => void): this;
|
|
421
|
+
addListener(event: "test:watch:restarted", listener: () => void): this;
|
|
405
422
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
406
423
|
emit(event: "test:coverage", data: EventData.TestCoverage): boolean;
|
|
407
424
|
emit(event: "test:complete", data: EventData.TestComplete): boolean;
|
|
@@ -416,6 +433,7 @@ declare module "node:test" {
|
|
|
416
433
|
emit(event: "test:stdout", data: EventData.TestStdout): boolean;
|
|
417
434
|
emit(event: "test:summary", data: EventData.TestSummary): boolean;
|
|
418
435
|
emit(event: "test:watch:drained"): boolean;
|
|
436
|
+
emit(event: "test:watch:restarted"): boolean;
|
|
419
437
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
420
438
|
on(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
421
439
|
on(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
@@ -430,6 +448,7 @@ declare module "node:test" {
|
|
|
430
448
|
on(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
431
449
|
on(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
432
450
|
on(event: "test:watch:drained", listener: () => void): this;
|
|
451
|
+
on(event: "test:watch:restarted", listener: () => void): this;
|
|
433
452
|
on(event: string, listener: (...args: any[]) => void): this;
|
|
434
453
|
once(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
435
454
|
once(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
@@ -444,6 +463,7 @@ declare module "node:test" {
|
|
|
444
463
|
once(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
445
464
|
once(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
446
465
|
once(event: "test:watch:drained", listener: () => void): this;
|
|
466
|
+
once(event: "test:watch:restarted", listener: () => void): this;
|
|
447
467
|
once(event: string, listener: (...args: any[]) => void): this;
|
|
448
468
|
prependListener(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
449
469
|
prependListener(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
@@ -458,6 +478,7 @@ declare module "node:test" {
|
|
|
458
478
|
prependListener(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
459
479
|
prependListener(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
460
480
|
prependListener(event: "test:watch:drained", listener: () => void): this;
|
|
481
|
+
prependListener(event: "test:watch:restarted", listener: () => void): this;
|
|
461
482
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
462
483
|
prependOnceListener(event: "test:coverage", listener: (data: EventData.TestCoverage) => void): this;
|
|
463
484
|
prependOnceListener(event: "test:complete", listener: (data: EventData.TestComplete) => void): this;
|
|
@@ -472,6 +493,7 @@ declare module "node:test" {
|
|
|
472
493
|
prependOnceListener(event: "test:stdout", listener: (data: EventData.TestStdout) => void): this;
|
|
473
494
|
prependOnceListener(event: "test:summary", listener: (data: EventData.TestSummary) => void): this;
|
|
474
495
|
prependOnceListener(event: "test:watch:drained", listener: () => void): this;
|
|
496
|
+
prependOnceListener(event: "test:watch:restarted", listener: () => void): this;
|
|
475
497
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
476
498
|
}
|
|
477
499
|
namespace EventData {
|
|
@@ -696,7 +718,7 @@ declare module "node:test" {
|
|
|
696
718
|
/**
|
|
697
719
|
* The type of the test, used to denote whether this is a suite.
|
|
698
720
|
*/
|
|
699
|
-
type?: "suite";
|
|
721
|
+
type?: "suite" | "test";
|
|
700
722
|
};
|
|
701
723
|
/**
|
|
702
724
|
* The test name.
|
|
@@ -766,7 +788,13 @@ declare module "node:test" {
|
|
|
766
788
|
* The type of the test, used to denote whether this is a suite.
|
|
767
789
|
* @since v20.0.0, v19.9.0, v18.17.0
|
|
768
790
|
*/
|
|
769
|
-
type?: "suite";
|
|
791
|
+
type?: "suite" | "test";
|
|
792
|
+
/**
|
|
793
|
+
* The attempt number of the test run,
|
|
794
|
+
* present only when using the `--test-rerun-failures` flag.
|
|
795
|
+
* @since v24.7.0
|
|
796
|
+
*/
|
|
797
|
+
attempt?: number;
|
|
770
798
|
};
|
|
771
799
|
/**
|
|
772
800
|
* The test name.
|
|
@@ -802,7 +830,19 @@ declare module "node:test" {
|
|
|
802
830
|
* The type of the test, used to denote whether this is a suite.
|
|
803
831
|
* @since 20.0.0, 19.9.0, 18.17.0
|
|
804
832
|
*/
|
|
805
|
-
type?: "suite";
|
|
833
|
+
type?: "suite" | "test";
|
|
834
|
+
/**
|
|
835
|
+
* The attempt number of the test run,
|
|
836
|
+
* present only when using the `--test-rerun-failures` flag.
|
|
837
|
+
* @since v24.7.0
|
|
838
|
+
*/
|
|
839
|
+
attempt?: number;
|
|
840
|
+
/**
|
|
841
|
+
* The attempt number the test passed on,
|
|
842
|
+
* present only when using the `--test-rerun-failures` flag.
|
|
843
|
+
* @since v24.7.0
|
|
844
|
+
*/
|
|
845
|
+
passed_on_attempt?: number;
|
|
806
846
|
};
|
|
807
847
|
/**
|
|
808
848
|
* The test name.
|
|
@@ -947,6 +987,7 @@ declare module "node:test" {
|
|
|
947
987
|
* @since v22.2.0, v20.15.0
|
|
948
988
|
*/
|
|
949
989
|
readonly assert: TestContextAssert;
|
|
990
|
+
readonly attempt: number;
|
|
950
991
|
/**
|
|
951
992
|
* This function is used to create a hook running before subtest of the current test.
|
|
952
993
|
* @param fn The hook function. The first argument to this function is a `TestContext` object.
|
|
@@ -1157,29 +1198,7 @@ declare module "node:test" {
|
|
|
1157
1198
|
*/
|
|
1158
1199
|
readonly mock: MockTracker;
|
|
1159
1200
|
}
|
|
1160
|
-
interface TestContextAssert extends
|
|
1161
|
-
Pick<
|
|
1162
|
-
typeof import("assert"),
|
|
1163
|
-
| "deepEqual"
|
|
1164
|
-
| "deepStrictEqual"
|
|
1165
|
-
| "doesNotMatch"
|
|
1166
|
-
| "doesNotReject"
|
|
1167
|
-
| "doesNotThrow"
|
|
1168
|
-
| "equal"
|
|
1169
|
-
| "fail"
|
|
1170
|
-
| "ifError"
|
|
1171
|
-
| "match"
|
|
1172
|
-
| "notDeepEqual"
|
|
1173
|
-
| "notDeepStrictEqual"
|
|
1174
|
-
| "notEqual"
|
|
1175
|
-
| "notStrictEqual"
|
|
1176
|
-
| "ok"
|
|
1177
|
-
| "partialDeepStrictEqual"
|
|
1178
|
-
| "rejects"
|
|
1179
|
-
| "strictEqual"
|
|
1180
|
-
| "throws"
|
|
1181
|
-
>
|
|
1182
|
-
{
|
|
1201
|
+
interface TestContextAssert extends Pick<typeof import("assert"), AssertMethodNames> {
|
|
1183
1202
|
/**
|
|
1184
1203
|
* This function serializes `value` and writes it to the file specified by `path`.
|
|
1185
1204
|
*
|
|
@@ -1199,7 +1218,7 @@ declare module "node:test" {
|
|
|
1199
1218
|
* highlighting.
|
|
1200
1219
|
* @since v22.14.0
|
|
1201
1220
|
* @param value A value to serialize to a string. If Node.js was started with
|
|
1202
|
-
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-
|
|
1221
|
+
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--test-update-snapshots)
|
|
1203
1222
|
* flag, the serialized value is written to
|
|
1204
1223
|
* `path`. Otherwise, the serialized value is compared to the contents of the
|
|
1205
1224
|
* existing snapshot file.
|
|
@@ -1222,7 +1241,7 @@ declare module "node:test" {
|
|
|
1222
1241
|
* ```
|
|
1223
1242
|
* @since v22.3.0
|
|
1224
1243
|
* @param value A value to serialize to a string. If Node.js was started with
|
|
1225
|
-
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-
|
|
1244
|
+
* the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--test-update-snapshots)
|
|
1226
1245
|
* flag, the serialized value is written to
|
|
1227
1246
|
* the snapshot file. Otherwise, the serialized value is compared to the
|
|
1228
1247
|
* corresponding value in the existing snapshot file.
|
|
@@ -1650,16 +1669,89 @@ declare module "node:test" {
|
|
|
1650
1669
|
options?: MockFunctionOptions,
|
|
1651
1670
|
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
|
|
1652
1671
|
/**
|
|
1653
|
-
* This function is used to mock the exports of ECMAScript modules, CommonJS modules,
|
|
1654
|
-
* Any references to the original module prior to mocking are not impacted.
|
|
1672
|
+
* This function is used to mock the exports of ECMAScript modules, CommonJS modules, JSON modules, and
|
|
1673
|
+
* Node.js builtin modules. Any references to the original module prior to mocking are not impacted. In
|
|
1674
|
+
* order to enable module mocking, Node.js must be started with the
|
|
1675
|
+
* [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--experimental-test-module-mocks)
|
|
1676
|
+
* command-line flag.
|
|
1677
|
+
*
|
|
1678
|
+
* The following example demonstrates how a mock is created for a module.
|
|
1679
|
+
*
|
|
1680
|
+
* ```js
|
|
1681
|
+
* test('mocks a builtin module in both module systems', async (t) => {
|
|
1682
|
+
* // Create a mock of 'node:readline' with a named export named 'fn', which
|
|
1683
|
+
* // does not exist in the original 'node:readline' module.
|
|
1684
|
+
* const mock = t.mock.module('node:readline', {
|
|
1685
|
+
* namedExports: { fn() { return 42; } },
|
|
1686
|
+
* });
|
|
1655
1687
|
*
|
|
1656
|
-
*
|
|
1688
|
+
* let esmImpl = await import('node:readline');
|
|
1689
|
+
* let cjsImpl = require('node:readline');
|
|
1690
|
+
*
|
|
1691
|
+
* // cursorTo() is an export of the original 'node:readline' module.
|
|
1692
|
+
* assert.strictEqual(esmImpl.cursorTo, undefined);
|
|
1693
|
+
* assert.strictEqual(cjsImpl.cursorTo, undefined);
|
|
1694
|
+
* assert.strictEqual(esmImpl.fn(), 42);
|
|
1695
|
+
* assert.strictEqual(cjsImpl.fn(), 42);
|
|
1696
|
+
*
|
|
1697
|
+
* mock.restore();
|
|
1698
|
+
*
|
|
1699
|
+
* // The mock is restored, so the original builtin module is returned.
|
|
1700
|
+
* esmImpl = await import('node:readline');
|
|
1701
|
+
* cjsImpl = require('node:readline');
|
|
1702
|
+
*
|
|
1703
|
+
* assert.strictEqual(typeof esmImpl.cursorTo, 'function');
|
|
1704
|
+
* assert.strictEqual(typeof cjsImpl.cursorTo, 'function');
|
|
1705
|
+
* assert.strictEqual(esmImpl.fn, undefined);
|
|
1706
|
+
* assert.strictEqual(cjsImpl.fn, undefined);
|
|
1707
|
+
* });
|
|
1708
|
+
* ```
|
|
1657
1709
|
* @since v22.3.0
|
|
1658
1710
|
* @experimental
|
|
1659
1711
|
* @param specifier A string identifying the module to mock.
|
|
1660
1712
|
* @param options Optional configuration options for the mock module.
|
|
1661
1713
|
*/
|
|
1662
1714
|
module(specifier: string, options?: MockModuleOptions): MockModuleContext;
|
|
1715
|
+
/**
|
|
1716
|
+
* Creates a mock for a property value on an object. This allows you to track and control access to a specific property,
|
|
1717
|
+
* including how many times it is read (getter) or written (setter), and to restore the original value after mocking.
|
|
1718
|
+
*
|
|
1719
|
+
* ```js
|
|
1720
|
+
* test('mocks a property value', (t) => {
|
|
1721
|
+
* const obj = { foo: 42 };
|
|
1722
|
+
* const prop = t.mock.property(obj, 'foo', 100);
|
|
1723
|
+
*
|
|
1724
|
+
* assert.strictEqual(obj.foo, 100);
|
|
1725
|
+
* assert.strictEqual(prop.mock.accessCount(), 1);
|
|
1726
|
+
* assert.strictEqual(prop.mock.accesses[0].type, 'get');
|
|
1727
|
+
* assert.strictEqual(prop.mock.accesses[0].value, 100);
|
|
1728
|
+
*
|
|
1729
|
+
* obj.foo = 200;
|
|
1730
|
+
* assert.strictEqual(prop.mock.accessCount(), 2);
|
|
1731
|
+
* assert.strictEqual(prop.mock.accesses[1].type, 'set');
|
|
1732
|
+
* assert.strictEqual(prop.mock.accesses[1].value, 200);
|
|
1733
|
+
*
|
|
1734
|
+
* prop.mock.restore();
|
|
1735
|
+
* assert.strictEqual(obj.foo, 42);
|
|
1736
|
+
* });
|
|
1737
|
+
* ```
|
|
1738
|
+
* @since v24.3.0
|
|
1739
|
+
* @param object The object whose value is being mocked.
|
|
1740
|
+
* @param propertyName The identifier of the property on `object` to mock.
|
|
1741
|
+
* @param value An optional value used as the mock value
|
|
1742
|
+
* for `object[propertyName]`. **Default:** The original property value.
|
|
1743
|
+
* @returns A proxy to the mocked object. The mocked object contains a
|
|
1744
|
+
* special `mock` property, which is an instance of [`MockPropertyContext`][], and
|
|
1745
|
+
* can be used for inspecting and changing the behavior of the mocked property.
|
|
1746
|
+
*/
|
|
1747
|
+
property<
|
|
1748
|
+
MockedObject extends object,
|
|
1749
|
+
PropertyName extends keyof MockedObject,
|
|
1750
|
+
>(
|
|
1751
|
+
object: MockedObject,
|
|
1752
|
+
property: PropertyName,
|
|
1753
|
+
value?: MockedObject[PropertyName],
|
|
1754
|
+
): MockedObject & { mock: MockPropertyContext<MockedObject[PropertyName]> };
|
|
1663
1755
|
/**
|
|
1664
1756
|
* This function restores the default behavior of all mocks that were previously
|
|
1665
1757
|
* 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
|
|
@@ -1829,6 +1921,70 @@ declare module "node:test" {
|
|
|
1829
1921
|
*/
|
|
1830
1922
|
restore(): void;
|
|
1831
1923
|
}
|
|
1924
|
+
/**
|
|
1925
|
+
* @since v24.3.0
|
|
1926
|
+
*/
|
|
1927
|
+
class MockPropertyContext<PropertyType = any> {
|
|
1928
|
+
/**
|
|
1929
|
+
* A getter that returns a copy of the internal array used to track accesses (get/set) to
|
|
1930
|
+
* the mocked property. Each entry in the array is an object with the following properties:
|
|
1931
|
+
*/
|
|
1932
|
+
readonly accesses: Array<{
|
|
1933
|
+
type: "get" | "set";
|
|
1934
|
+
value: PropertyType;
|
|
1935
|
+
stack: Error;
|
|
1936
|
+
}>;
|
|
1937
|
+
/**
|
|
1938
|
+
* This function returns the number of times that the property was accessed.
|
|
1939
|
+
* This function is more efficient than checking `ctx.accesses.length` because
|
|
1940
|
+
* `ctx.accesses` is a getter that creates a copy of the internal access tracking array.
|
|
1941
|
+
* @returns The number of times that the property was accessed (read or written).
|
|
1942
|
+
*/
|
|
1943
|
+
accessCount(): number;
|
|
1944
|
+
/**
|
|
1945
|
+
* This function is used to change the value returned by the mocked property getter.
|
|
1946
|
+
* @param value The new value to be set as the mocked property value.
|
|
1947
|
+
*/
|
|
1948
|
+
mockImplementation(value: PropertyType): void;
|
|
1949
|
+
/**
|
|
1950
|
+
* This function is used to change the behavior of an existing mock for a single
|
|
1951
|
+
* invocation. Once invocation `onAccess` has occurred, the mock will revert to
|
|
1952
|
+
* whatever behavior it would have used had `mockImplementationOnce()` not been
|
|
1953
|
+
* called.
|
|
1954
|
+
*
|
|
1955
|
+
* The following example creates a mock function using `t.mock.property()`, calls the
|
|
1956
|
+
* mock property, changes the mock implementation to a different value for the
|
|
1957
|
+
* next invocation, and then resumes its previous behavior.
|
|
1958
|
+
*
|
|
1959
|
+
* ```js
|
|
1960
|
+
* test('changes a mock behavior once', (t) => {
|
|
1961
|
+
* const obj = { foo: 1 };
|
|
1962
|
+
*
|
|
1963
|
+
* const prop = t.mock.property(obj, 'foo', 5);
|
|
1964
|
+
*
|
|
1965
|
+
* assert.strictEqual(obj.foo, 5);
|
|
1966
|
+
* prop.mock.mockImplementationOnce(25);
|
|
1967
|
+
* assert.strictEqual(obj.foo, 25);
|
|
1968
|
+
* assert.strictEqual(obj.foo, 5);
|
|
1969
|
+
* });
|
|
1970
|
+
* ```
|
|
1971
|
+
* @param value The value to be used as the mock's
|
|
1972
|
+
* implementation for the invocation number specified by `onAccess`.
|
|
1973
|
+
* @param onAccess The invocation number that will use `value`. If
|
|
1974
|
+
* the specified invocation has already occurred then an exception is thrown.
|
|
1975
|
+
* **Default:** The number of the next invocation.
|
|
1976
|
+
*/
|
|
1977
|
+
mockImplementationOnce(value: PropertyType, onAccess?: number): void;
|
|
1978
|
+
/**
|
|
1979
|
+
* Resets the access history of the mocked property.
|
|
1980
|
+
*/
|
|
1981
|
+
resetAccesses(): void;
|
|
1982
|
+
/**
|
|
1983
|
+
* Resets the implementation of the mock property to its original behavior. The
|
|
1984
|
+
* mock can still be used after calling this function.
|
|
1985
|
+
*/
|
|
1986
|
+
restore(): void;
|
|
1987
|
+
}
|
|
1832
1988
|
interface MockTimersOptions {
|
|
1833
1989
|
apis: ReadonlyArray<"setInterval" | "setTimeout" | "setImmediate" | "Date">;
|
|
1834
1990
|
now?: number | Date | undefined;
|
|
@@ -1844,7 +2000,6 @@ declare module "node:test" {
|
|
|
1844
2000
|
* The `MockTracker` provides a top-level `timers` export
|
|
1845
2001
|
* which is a `MockTimers` instance.
|
|
1846
2002
|
* @since v20.4.0
|
|
1847
|
-
* @experimental
|
|
1848
2003
|
*/
|
|
1849
2004
|
interface MockTimers {
|
|
1850
2005
|
/**
|
|
@@ -2117,7 +2272,7 @@ declare module "node:test" {
|
|
|
2117
2272
|
* import test from 'node:test/reporters';
|
|
2118
2273
|
* ```
|
|
2119
2274
|
* @since v19.9.0
|
|
2120
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
2275
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/test/reporters.js)
|
|
2121
2276
|
*/
|
|
2122
2277
|
declare module "node:test/reporters" {
|
|
2123
2278
|
import { Transform, TransformOptions } from "node:stream";
|
|
@@ -2136,7 +2291,8 @@ declare module "node:test/reporters" {
|
|
|
2136
2291
|
| { type: "test:stderr"; data: EventData.TestStderr }
|
|
2137
2292
|
| { type: "test:stdout"; data: EventData.TestStdout }
|
|
2138
2293
|
| { type: "test:summary"; data: EventData.TestSummary }
|
|
2139
|
-
| { type: "test:watch:drained"; data: undefined }
|
|
2294
|
+
| { type: "test:watch:drained"; data: undefined }
|
|
2295
|
+
| { type: "test:watch:restarted"; data: undefined };
|
|
2140
2296
|
type TestEventGenerator = AsyncGenerator<TestEvent, void>;
|
|
2141
2297
|
|
|
2142
2298
|
interface ReporterConstructorWrapper<T extends new(...args: any[]) => Transform> {
|
|
@@ -2174,10 +2330,10 @@ declare module "node:test/reporters" {
|
|
|
2174
2330
|
}
|
|
2175
2331
|
/**
|
|
2176
2332
|
* The `lcov` reporter outputs test coverage when used with the
|
|
2177
|
-
* [`--experimental-test-coverage`](https://nodejs.org/docs/latest-
|
|
2333
|
+
* [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--experimental-test-coverage) flag.
|
|
2178
2334
|
* @since v22.0.0
|
|
2179
2335
|
*/
|
|
2180
|
-
const lcov: LcovReporter
|
|
2336
|
+
const lcov: ReporterConstructorWrapper<typeof LcovReporter>;
|
|
2181
2337
|
|
|
2182
2338
|
export { dot, junit, lcov, spec, tap, TestEvent };
|
|
2183
2339
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* } from 'node:timers/promises';
|
|
12
12
|
* ```
|
|
13
13
|
* @since v15.0.0
|
|
14
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
14
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/timers/promises.js)
|
|
15
15
|
*/
|
|
16
16
|
declare module "timers/promises" {
|
|
17
17
|
import { TimerOptions } from "node:timers";
|