diff --git a/types/node/test.d.ts b/types/node/test.d.ts index 614f94d5099aea..3d1cb9ce914252 100644 --- a/types/node/test.d.ts +++ b/types/node/test.d.ts @@ -171,21 +171,21 @@ declare module 'node:test' { * The `it()` function is imported from the `node:test` module. * @since v18.6.0, v16.17.0 */ - function it(name?: string, options?: TestOptions, fn?: ItFn): void; - function it(name?: string, fn?: ItFn): void; - function it(options?: TestOptions, fn?: ItFn): void; - function it(fn?: ItFn): void; + function it(name?: string, options?: TestOptions, fn?: TestFn): void; + function it(name?: string, fn?: TestFn): void; + function it(options?: TestOptions, fn?: TestFn): void; + function it(fn?: TestFn): void; namespace it { // Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. - function skip(name?: string, options?: TestOptions, fn?: ItFn): void; - function skip(name?: string, fn?: ItFn): void; - function skip(options?: TestOptions, fn?: ItFn): void; - function skip(fn?: ItFn): void; + function skip(name?: string, options?: TestOptions, fn?: TestFn): void; + function skip(name?: string, fn?: TestFn): void; + function skip(options?: TestOptions, fn?: TestFn): void; + function skip(fn?: TestFn): void; // Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. - function todo(name?: string, options?: TestOptions, fn?: ItFn): void; - function todo(name?: string, fn?: ItFn): void; - function todo(options?: TestOptions, fn?: ItFn): void; - function todo(fn?: ItFn): void; + function todo(name?: string, options?: TestOptions, fn?: TestFn): void; + function todo(name?: string, fn?: TestFn): void; + function todo(options?: TestOptions, fn?: TestFn): void; + function todo(fn?: TestFn): void; } /** * The type of a function under test. The first argument to this function is a @@ -198,11 +198,6 @@ declare module 'node:test' { * If the test uses callbacks, the callback function is passed as an argument */ type SuiteFn = (done: (result?: any) => void) => void; - /** - * The type of a function under test. - * If the test uses callbacks, the callback function is passed as an argument - */ - type ItFn = (done: (result?: any) => void) => any; interface RunOptions { /** * If a number is provided, then that many files would run in parallel. diff --git a/types/node/test/test.ts b/types/node/test/test.ts index f0249511edeae4..16935135284696 100644 --- a/types/node/test/test.ts +++ b/types/node/test/test.ts @@ -167,7 +167,9 @@ describe(cb => { }); // Test callback mode -it(cb => { +it((t, cb) => { + // $ExpectType TestContext + t; // $ExpectType (result?: any) => void cb; // $ExpectType void diff --git a/types/node/v18/test.d.ts b/types/node/v18/test.d.ts index b8c8e9c66ddd94..0196cbc10f72fc 100644 --- a/types/node/v18/test.d.ts +++ b/types/node/v18/test.d.ts @@ -83,22 +83,22 @@ declare module 'node:test' { * @param fn The function under test. If the test uses callbacks, the callback function is * passed as the second argument. Default: A no-op function. */ - function it(name?: string, options?: TestOptions, fn?: ItFn): void; - function it(name?: string, fn?: ItFn): void; - function it(options?: TestOptions, fn?: ItFn): void; - function it(fn?: ItFn): void; + function it(name?: string, options?: TestOptions, fn?: TestFn): void; + function it(name?: string, fn?: TestFn): void; + function it(options?: TestOptions, fn?: TestFn): void; + function it(fn?: TestFn): void; namespace it { // Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. - function skip(name?: string, options?: TestOptions, fn?: ItFn): void; - function skip(name?: string, fn?: ItFn): void; - function skip(options?: TestOptions, fn?: ItFn): void; - function skip(fn?: ItFn): void; + function skip(name?: string, options?: TestOptions, fn?: TestFn): void; + function skip(name?: string, fn?: TestFn): void; + function skip(options?: TestOptions, fn?: TestFn): void; + function skip(fn?: TestFn): void; // Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. - function todo(name?: string, options?: TestOptions, fn?: ItFn): void; - function todo(name?: string, fn?: ItFn): void; - function todo(options?: TestOptions, fn?: ItFn): void; - function todo(fn?: ItFn): void; + function todo(name?: string, options?: TestOptions, fn?: TestFn): void; + function todo(name?: string, fn?: TestFn): void; + function todo(options?: TestOptions, fn?: TestFn): void; + function todo(fn?: TestFn): void; } /** @@ -114,12 +114,6 @@ declare module 'node:test' { */ type SuiteFn = (done: (result?: any) => void) => void; - /** - * The type of a function under test. - * If the test uses callbacks, the callback function is passed as an argument - */ - type ItFn = (done: (result?: any) => void) => any; - interface RunOptions { /** * If a number is provided, then that many files would run in parallel. diff --git a/types/node/v18/test/test.ts b/types/node/v18/test/test.ts index 04431772b7c186..1c9cdf45004016 100644 --- a/types/node/v18/test/test.ts +++ b/types/node/v18/test/test.ts @@ -164,7 +164,9 @@ describe(cb => { }); // Test callback mode -it(cb => { +it((t, cb) => { + // $ExpectType TestContext + t; // $ExpectType (result?: any) => void cb; // $ExpectType void diff --git a/types/node/v18/ts4.8/test.d.ts b/types/node/v18/ts4.8/test.d.ts index b8c8e9c66ddd94..0196cbc10f72fc 100644 --- a/types/node/v18/ts4.8/test.d.ts +++ b/types/node/v18/ts4.8/test.d.ts @@ -83,22 +83,22 @@ declare module 'node:test' { * @param fn The function under test. If the test uses callbacks, the callback function is * passed as the second argument. Default: A no-op function. */ - function it(name?: string, options?: TestOptions, fn?: ItFn): void; - function it(name?: string, fn?: ItFn): void; - function it(options?: TestOptions, fn?: ItFn): void; - function it(fn?: ItFn): void; + function it(name?: string, options?: TestOptions, fn?: TestFn): void; + function it(name?: string, fn?: TestFn): void; + function it(options?: TestOptions, fn?: TestFn): void; + function it(fn?: TestFn): void; namespace it { // Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. - function skip(name?: string, options?: TestOptions, fn?: ItFn): void; - function skip(name?: string, fn?: ItFn): void; - function skip(options?: TestOptions, fn?: ItFn): void; - function skip(fn?: ItFn): void; + function skip(name?: string, options?: TestOptions, fn?: TestFn): void; + function skip(name?: string, fn?: TestFn): void; + function skip(options?: TestOptions, fn?: TestFn): void; + function skip(fn?: TestFn): void; // Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. - function todo(name?: string, options?: TestOptions, fn?: ItFn): void; - function todo(name?: string, fn?: ItFn): void; - function todo(options?: TestOptions, fn?: ItFn): void; - function todo(fn?: ItFn): void; + function todo(name?: string, options?: TestOptions, fn?: TestFn): void; + function todo(name?: string, fn?: TestFn): void; + function todo(options?: TestOptions, fn?: TestFn): void; + function todo(fn?: TestFn): void; } /** @@ -114,12 +114,6 @@ declare module 'node:test' { */ type SuiteFn = (done: (result?: any) => void) => void; - /** - * The type of a function under test. - * If the test uses callbacks, the callback function is passed as an argument - */ - type ItFn = (done: (result?: any) => void) => any; - interface RunOptions { /** * If a number is provided, then that many files would run in parallel. diff --git a/types/node/v18/ts4.8/test/test.ts b/types/node/v18/ts4.8/test/test.ts index 04431772b7c186..1c9cdf45004016 100644 --- a/types/node/v18/ts4.8/test/test.ts +++ b/types/node/v18/ts4.8/test/test.ts @@ -164,7 +164,9 @@ describe(cb => { }); // Test callback mode -it(cb => { +it((t, cb) => { + // $ExpectType TestContext + t; // $ExpectType (result?: any) => void cb; // $ExpectType void