Skip to content

Commit fc95df9

Browse files
committed
Export suite from node:test, add tests
1 parent b37794d commit fc95df9

4 files changed

Lines changed: 214 additions & 2 deletions

File tree

types/node/test.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ declare module "node:test" {
144144
function test(options?: TestOptions, fn?: TestFn): Promise<void>;
145145
function test(fn?: TestFn): Promise<void>;
146146
namespace test {
147-
export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, test, todo };
147+
export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, suite, test, todo };
148148
}
149149
/**
150150
* The `suite()` function is imported from the `node:test` module.
@@ -1326,6 +1326,7 @@ declare module "node:test" {
13261326
only,
13271327
run,
13281328
skip,
1329+
suite,
13291330
SuiteContext,
13301331
test,
13311332
test as default,

types/node/test/test.ts

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
only,
1212
run,
1313
skip,
14+
suite,
1415
type SuiteContext,
1516
test,
1617
type TestContext,
@@ -150,6 +151,7 @@ test.test.test("chained self ref", (t) => {
150151
t.test;
151152
});
152153
test.skip("skip", () => {});
154+
test.suite("suite", () => {});
153155
test.todo("todo", () => {});
154156
test.only("only", () => {});
155157

@@ -330,6 +332,109 @@ describe(1, () => {});
330332
// @ts-expect-error
331333
it(1, () => {});
332334

335+
// suite() signatures
336+
// $ExpectType Promise<void>
337+
suite();
338+
// $ExpectType Promise<void>
339+
suite("foo");
340+
// $ExpectType Promise<void>
341+
suite("foo", () => {});
342+
// $ExpectType Promise<void>
343+
suite("foo", {
344+
concurrency: false,
345+
only: true,
346+
signal: new AbortController().signal,
347+
skip: false,
348+
timeout: 30_000,
349+
todo: true,
350+
});
351+
// $ExpectType Promise<void>
352+
suite("foo", {
353+
concurrency: 5,
354+
todo: "foo",
355+
}, async () => {});
356+
// $ExpectType Promise<void>
357+
suite(() => {});
358+
359+
// suite.skip() signatures
360+
// $ExpectType Promise<void>
361+
suite.skip();
362+
// $ExpectType Promise<void>
363+
suite.skip("foo");
364+
// $ExpectType Promise<void>
365+
suite.skip("foo", () => {});
366+
// $ExpectType Promise<void>
367+
suite.skip("foo", {
368+
concurrency: false,
369+
only: true,
370+
signal: new AbortController().signal,
371+
timeout: 30_000,
372+
todo: true,
373+
});
374+
// $ExpectType Promise<void>
375+
suite.skip("foo", {
376+
concurrency: 5,
377+
todo: "foo",
378+
}, async () => {});
379+
// $ExpectType Promise<void>
380+
suite.skip(() => {});
381+
382+
// suite.todo() signatures
383+
// $ExpectType Promise<void>
384+
suite.todo();
385+
// $ExpectType Promise<void>
386+
suite.todo("foo");
387+
// $ExpectType Promise<void>
388+
suite.todo("foo", () => {});
389+
// $ExpectType Promise<void>
390+
suite.todo("foo", {
391+
concurrency: false,
392+
only: true,
393+
signal: new AbortController().signal,
394+
skip: false,
395+
timeout: 30_000,
396+
});
397+
// $ExpectType Promise<void>
398+
suite.todo("foo", {
399+
concurrency: 5,
400+
timeout: Infinity,
401+
}, async () => {});
402+
// $ExpectType Promise<void>
403+
suite.todo(() => {});
404+
405+
// suite.only() signatures
406+
// $ExpectType Promise<void>
407+
suite.only();
408+
// $ExpectType Promise<void>
409+
suite.only("foo");
410+
// $ExpectType Promise<void>
411+
suite.only("foo", () => {});
412+
// $ExpectType Promise<void>
413+
suite.only("foo", {
414+
concurrency: false,
415+
signal: new AbortController().signal,
416+
skip: false,
417+
timeout: 30_000,
418+
todo: true,
419+
});
420+
// $ExpectType Promise<void>
421+
suite.only("foo", {
422+
concurrency: 5,
423+
todo: "foo",
424+
}, async () => {});
425+
// $ExpectType Promise<void>
426+
suite.only(() => {});
427+
428+
// SuiteContext
429+
suite("foo", (context) => {
430+
// $ExpectType SuiteContext
431+
context;
432+
// $ExpectType string
433+
context.name;
434+
// $ExpectType AbortSignal
435+
context.signal;
436+
});
437+
333438
// Hooks
334439
// - without callback
335440
before(() => {});

types/node/v20/test.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ declare module "node:test" {
144144
function test(options?: TestOptions, fn?: TestFn): Promise<void>;
145145
function test(fn?: TestFn): Promise<void>;
146146
namespace test {
147-
export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, test, todo };
147+
export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, suite, test, todo };
148148
}
149149
/**
150150
* The `suite()` function is imported from the `node:test` module.
@@ -1315,6 +1315,7 @@ declare module "node:test" {
13151315
only,
13161316
run,
13171317
skip,
1318+
suite,
13181319
SuiteContext,
13191320
test,
13201321
test as default,

types/node/v20/test/test.ts

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
only,
1212
run,
1313
skip,
14+
suite,
1415
type SuiteContext,
1516
test,
1617
type TestContext,
@@ -143,6 +144,7 @@ test.describe("describe", () => {});
143144
test.it("it", () => {});
144145
// $ExpectType MockTracker
145146
test.mock;
147+
test.suite("suite", () => {});
146148
// $ExpectType typeof test
147149
test.test;
148150
test.test.test("chained self ref", (t) => {
@@ -330,6 +332,109 @@ describe(1, () => {});
330332
// @ts-expect-error
331333
it(1, () => {});
332334

335+
// suite() signatures
336+
// $ExpectType Promise<void>
337+
suite();
338+
// $ExpectType Promise<void>
339+
suite("foo");
340+
// $ExpectType Promise<void>
341+
suite("foo", () => {});
342+
// $ExpectType Promise<void>
343+
suite("foo", {
344+
concurrency: false,
345+
only: true,
346+
signal: new AbortController().signal,
347+
skip: false,
348+
timeout: 30_000,
349+
todo: true,
350+
});
351+
// $ExpectType Promise<void>
352+
suite("foo", {
353+
concurrency: 5,
354+
todo: "foo",
355+
}, async () => {});
356+
// $ExpectType Promise<void>
357+
suite(() => {});
358+
359+
// suite.skip() signatures
360+
// $ExpectType Promise<void>
361+
suite.skip();
362+
// $ExpectType Promise<void>
363+
suite.skip("foo");
364+
// $ExpectType Promise<void>
365+
suite.skip("foo", () => {});
366+
// $ExpectType Promise<void>
367+
suite.skip("foo", {
368+
concurrency: false,
369+
only: true,
370+
signal: new AbortController().signal,
371+
timeout: 30_000,
372+
todo: true,
373+
});
374+
// $ExpectType Promise<void>
375+
suite.skip("foo", {
376+
concurrency: 5,
377+
todo: "foo",
378+
}, async () => {});
379+
// $ExpectType Promise<void>
380+
suite.skip(() => {});
381+
382+
// suite.todo() signatures
383+
// $ExpectType Promise<void>
384+
suite.todo();
385+
// $ExpectType Promise<void>
386+
suite.todo("foo");
387+
// $ExpectType Promise<void>
388+
suite.todo("foo", () => {});
389+
// $ExpectType Promise<void>
390+
suite.todo("foo", {
391+
concurrency: false,
392+
only: true,
393+
signal: new AbortController().signal,
394+
skip: false,
395+
timeout: 30_000,
396+
});
397+
// $ExpectType Promise<void>
398+
suite.todo("foo", {
399+
concurrency: 5,
400+
timeout: Infinity,
401+
}, async () => {});
402+
// $ExpectType Promise<void>
403+
suite.todo(() => {});
404+
405+
// suite.only() signatures
406+
// $ExpectType Promise<void>
407+
suite.only();
408+
// $ExpectType Promise<void>
409+
suite.only("foo");
410+
// $ExpectType Promise<void>
411+
suite.only("foo", () => {});
412+
// $ExpectType Promise<void>
413+
suite.only("foo", {
414+
concurrency: false,
415+
signal: new AbortController().signal,
416+
skip: false,
417+
timeout: 30_000,
418+
todo: true,
419+
});
420+
// $ExpectType Promise<void>
421+
suite.only("foo", {
422+
concurrency: 5,
423+
todo: "foo",
424+
}, async () => {});
425+
// $ExpectType Promise<void>
426+
suite.only(() => {});
427+
428+
// SuiteContext
429+
suite("foo", (context) => {
430+
// $ExpectType SuiteContext
431+
context;
432+
// $ExpectType string
433+
context.name;
434+
// $ExpectType AbortSignal
435+
context.signal;
436+
});
437+
333438
// Hooks
334439
// - without callback
335440
before(() => {});

0 commit comments

Comments
 (0)