Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions types/node/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion types/node/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ describe(cb => {
});

// Test callback mode
it(cb => {
it((t, cb) => {
// $ExpectType TestContext
t;
// $ExpectType (result?: any) => void
cb;
// $ExpectType void
Expand Down
30 changes: 12 additions & 18 deletions types/node/v18/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion types/node/v18/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ describe(cb => {
});

// Test callback mode
it(cb => {
it((t, cb) => {
// $ExpectType TestContext
t;
// $ExpectType (result?: any) => void
cb;
// $ExpectType void
Expand Down
30 changes: 12 additions & 18 deletions types/node/v18/ts4.8/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion types/node/v18/ts4.8/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ describe(cb => {
});

// Test callback mode
it(cb => {
it((t, cb) => {
// $ExpectType TestContext
t;
// $ExpectType (result?: any) => void
cb;
// $ExpectType void
Expand Down