Skip to content

Commit 7f7ec8c

Browse files
antongolubDesplandis
authored andcommitted
1 parent 720fe8e commit 7f7ec8c

6 files changed

Lines changed: 45 additions & 56 deletions

File tree

‎types/node/test.d.ts‎

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,21 @@ declare module 'node:test' {
171171
* The `it()` function is imported from the `node:test` module.
172172
* @since v18.6.0, v16.17.0
173173
*/
174-
function it(name?: string, options?: TestOptions, fn?: ItFn): void;
175-
function it(name?: string, fn?: ItFn): void;
176-
function it(options?: TestOptions, fn?: ItFn): void;
177-
function it(fn?: ItFn): void;
174+
function it(name?: string, options?: TestOptions, fn?: TestFn): void;
175+
function it(name?: string, fn?: TestFn): void;
176+
function it(options?: TestOptions, fn?: TestFn): void;
177+
function it(fn?: TestFn): void;
178178
namespace it {
179179
// Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
180-
function skip(name?: string, options?: TestOptions, fn?: ItFn): void;
181-
function skip(name?: string, fn?: ItFn): void;
182-
function skip(options?: TestOptions, fn?: ItFn): void;
183-
function skip(fn?: ItFn): void;
180+
function skip(name?: string, options?: TestOptions, fn?: TestFn): void;
181+
function skip(name?: string, fn?: TestFn): void;
182+
function skip(options?: TestOptions, fn?: TestFn): void;
183+
function skip(fn?: TestFn): void;
184184
// Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
185-
function todo(name?: string, options?: TestOptions, fn?: ItFn): void;
186-
function todo(name?: string, fn?: ItFn): void;
187-
function todo(options?: TestOptions, fn?: ItFn): void;
188-
function todo(fn?: ItFn): void;
185+
function todo(name?: string, options?: TestOptions, fn?: TestFn): void;
186+
function todo(name?: string, fn?: TestFn): void;
187+
function todo(options?: TestOptions, fn?: TestFn): void;
188+
function todo(fn?: TestFn): void;
189189
}
190190
/**
191191
* The type of a function under test. The first argument to this function is a
@@ -198,11 +198,6 @@ declare module 'node:test' {
198198
* If the test uses callbacks, the callback function is passed as an argument
199199
*/
200200
type SuiteFn = (done: (result?: any) => void) => void;
201-
/**
202-
* The type of a function under test.
203-
* If the test uses callbacks, the callback function is passed as an argument
204-
*/
205-
type ItFn = (done: (result?: any) => void) => any;
206201
interface RunOptions {
207202
/**
208203
* If a number is provided, then that many files would run in parallel.

‎types/node/test/test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ describe(cb => {
167167
});
168168

169169
// Test callback mode
170-
it(cb => {
170+
it((t, cb) => {
171+
// $ExpectType TestContext
172+
t;
171173
// $ExpectType (result?: any) => void
172174
cb;
173175
// $ExpectType void

‎types/node/v18/test.d.ts‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,22 @@ declare module 'node:test' {
8383
* @param fn The function under test. If the test uses callbacks, the callback function is
8484
* passed as the second argument. Default: A no-op function.
8585
*/
86-
function it(name?: string, options?: TestOptions, fn?: ItFn): void;
87-
function it(name?: string, fn?: ItFn): void;
88-
function it(options?: TestOptions, fn?: ItFn): void;
89-
function it(fn?: ItFn): void;
86+
function it(name?: string, options?: TestOptions, fn?: TestFn): void;
87+
function it(name?: string, fn?: TestFn): void;
88+
function it(options?: TestOptions, fn?: TestFn): void;
89+
function it(fn?: TestFn): void;
9090
namespace it {
9191
// Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
92-
function skip(name?: string, options?: TestOptions, fn?: ItFn): void;
93-
function skip(name?: string, fn?: ItFn): void;
94-
function skip(options?: TestOptions, fn?: ItFn): void;
95-
function skip(fn?: ItFn): void;
92+
function skip(name?: string, options?: TestOptions, fn?: TestFn): void;
93+
function skip(name?: string, fn?: TestFn): void;
94+
function skip(options?: TestOptions, fn?: TestFn): void;
95+
function skip(fn?: TestFn): void;
9696

9797
// Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
98-
function todo(name?: string, options?: TestOptions, fn?: ItFn): void;
99-
function todo(name?: string, fn?: ItFn): void;
100-
function todo(options?: TestOptions, fn?: ItFn): void;
101-
function todo(fn?: ItFn): void;
98+
function todo(name?: string, options?: TestOptions, fn?: TestFn): void;
99+
function todo(name?: string, fn?: TestFn): void;
100+
function todo(options?: TestOptions, fn?: TestFn): void;
101+
function todo(fn?: TestFn): void;
102102
}
103103

104104
/**
@@ -114,12 +114,6 @@ declare module 'node:test' {
114114
*/
115115
type SuiteFn = (done: (result?: any) => void) => void;
116116

117-
/**
118-
* The type of a function under test.
119-
* If the test uses callbacks, the callback function is passed as an argument
120-
*/
121-
type ItFn = (done: (result?: any) => void) => any;
122-
123117
interface RunOptions {
124118
/**
125119
* If a number is provided, then that many files would run in parallel.

‎types/node/v18/test/test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ describe(cb => {
164164
});
165165

166166
// Test callback mode
167-
it(cb => {
167+
it((t, cb) => {
168+
// $ExpectType TestContext
169+
t;
168170
// $ExpectType (result?: any) => void
169171
cb;
170172
// $ExpectType void

‎types/node/v18/ts4.8/test.d.ts‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,22 @@ declare module 'node:test' {
8383
* @param fn The function under test. If the test uses callbacks, the callback function is
8484
* passed as the second argument. Default: A no-op function.
8585
*/
86-
function it(name?: string, options?: TestOptions, fn?: ItFn): void;
87-
function it(name?: string, fn?: ItFn): void;
88-
function it(options?: TestOptions, fn?: ItFn): void;
89-
function it(fn?: ItFn): void;
86+
function it(name?: string, options?: TestOptions, fn?: TestFn): void;
87+
function it(name?: string, fn?: TestFn): void;
88+
function it(options?: TestOptions, fn?: TestFn): void;
89+
function it(fn?: TestFn): void;
9090
namespace it {
9191
// Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
92-
function skip(name?: string, options?: TestOptions, fn?: ItFn): void;
93-
function skip(name?: string, fn?: ItFn): void;
94-
function skip(options?: TestOptions, fn?: ItFn): void;
95-
function skip(fn?: ItFn): void;
92+
function skip(name?: string, options?: TestOptions, fn?: TestFn): void;
93+
function skip(name?: string, fn?: TestFn): void;
94+
function skip(options?: TestOptions, fn?: TestFn): void;
95+
function skip(fn?: TestFn): void;
9696

9797
// Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
98-
function todo(name?: string, options?: TestOptions, fn?: ItFn): void;
99-
function todo(name?: string, fn?: ItFn): void;
100-
function todo(options?: TestOptions, fn?: ItFn): void;
101-
function todo(fn?: ItFn): void;
98+
function todo(name?: string, options?: TestOptions, fn?: TestFn): void;
99+
function todo(name?: string, fn?: TestFn): void;
100+
function todo(options?: TestOptions, fn?: TestFn): void;
101+
function todo(fn?: TestFn): void;
102102
}
103103

104104
/**
@@ -114,12 +114,6 @@ declare module 'node:test' {
114114
*/
115115
type SuiteFn = (done: (result?: any) => void) => void;
116116

117-
/**
118-
* The type of a function under test.
119-
* If the test uses callbacks, the callback function is passed as an argument
120-
*/
121-
type ItFn = (done: (result?: any) => void) => any;
122-
123117
interface RunOptions {
124118
/**
125119
* If a number is provided, then that many files would run in parallel.

‎types/node/v18/ts4.8/test/test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ describe(cb => {
164164
});
165165

166166
// Test callback mode
167-
it(cb => {
167+
it((t, cb) => {
168+
// $ExpectType TestContext
169+
t;
168170
// $ExpectType (result?: any) => void
169171
cb;
170172
// $ExpectType void

0 commit comments

Comments
 (0)