Skip to content

Commit

Permalink
feat(bun:test) add support for test.each() and describe.each() (#4047)
Browse files Browse the repository at this point in the history
* rename callback to func

* update testscope to handle function arguments

* works

* big cleanup

* works in debug, not release

* fix memory issue & update tests

* catch & str test

* write types for each() & switch tests to ts

* rm & typo

* move some code around & support describe

* review changes
  • Loading branch information
jecquas authored and Jarred-Sumner committed Aug 11, 2023
1 parent 6e25e12 commit 6f230fc
Show file tree
Hide file tree
Showing 3 changed files with 324 additions and 16 deletions.
38 changes: 38 additions & 0 deletions packages/bun-types/bun-test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@ declare module "bun:test" {
* @param condition if these tests should be skipped
*/
skipIf(condition: boolean): (label: string, fn: () => void) => void;
/**
* Returns a function that runs for each item in `table`.
*
* @param table Array of Arrays with the arguments that are passed into the test fn for each row.
*/
each<T extends ReadonlyArray<unknown>>(
table: ReadonlyArray<T>,
): (
label: string,
fn: (...args: T) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
each<T>(
table: ReadonlyArray<T>,
): (
label: string,
fn: (arg: T) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
};
/**
* Describes a group of related tests.
Expand Down Expand Up @@ -395,6 +414,25 @@ declare module "bun:test" {
| ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
) => void;
/**
* Returns a function that runs for each item in `table`.
*
* @param table Array of Arrays with the arguments that are passed into the test fn for each row.
*/
each<T extends ReadonlyArray<unknown>>(
table: ReadonlyArray<T>,
): (
label: string,
fn: (...args: T) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
each<T>(
table: ReadonlyArray<T>,
): (
label: string,
fn: (arg: T, done: (err?: unknown) => void) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
};
/**
* Runs a test.
Expand Down
Loading

0 comments on commit 6f230fc

Please sign in to comment.