Skip to content

Commit 31e2de7

Browse files
committed
[node:test] add setup and watch for RunOptions
1 parent 77b183c commit 31e2de7

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

types/node/test.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
*
7777
* If any tests fail, the process exit code is set to `1`.
7878
* @since v18.0.0, v16.17.0
79-
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test.js)
79+
* @see [source](https://github.com/nodejs/node/blob/v20.4.0/lib/test.js)
8080
*/
8181
declare module 'node:test' {
8282
import { Readable } from 'node:stream';
@@ -295,6 +295,14 @@ declare module 'node:test' {
295295
* For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run.
296296
*/
297297
testNamePatterns?: string | RegExp | string[] | RegExp[];
298+
/**
299+
* A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run.
300+
*/
301+
setup?: (root: unknown) => void | Promise<void>
302+
/**
303+
* Whether to run in watch mode or not. Default: false.
304+
*/
305+
watch?: boolean
298306
}
299307
/**
300308
* A successful call to `run()` method will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.`TestsStream` will emit events, in the

types/node/test/test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ run({
2020
timeout: 100,
2121
inspectPort: () => 8081,
2222
testNamePatterns: ['executed'],
23+
setup: () => {},
24+
watch: true
2325
});
2426

2527
// TestsStream should be a NodeJS.ReadableStream

0 commit comments

Comments
 (0)