aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorGravatar Jacques <25390037+jecquas@users.noreply.github.com> 2023-08-09 07:25:32 +0200
committerGravatar GitHub <noreply@github.com> 2023-08-08 22:25:32 -0700
commit63f58f40267856ef5e8ff3e8b0c5720a6d870873 (patch)
treea4098acc2ac5339511f9db43666c780fe0d5837a /packages
parent009fe18fa269247ae533608fa524c442b69b8f3a (diff)
downloadbun-63f58f40267856ef5e8ff3e8b0c5720a6d870873.tar.gz
bun-63f58f40267856ef5e8ff3e8b0c5720a6d870873.tar.zst
bun-63f58f40267856ef5e8ff3e8b0c5720a6d870873.zip
feat(bun:test) add support for test.each() and describe.each() (#4047)
* 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
Diffstat (limited to 'packages')
-rw-r--r--packages/bun-types/bun-test.d.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/packages/bun-types/bun-test.d.ts b/packages/bun-types/bun-test.d.ts
index f6e968906..790d8bfea 100644
--- a/packages/bun-types/bun-test.d.ts
+++ b/packages/bun-types/bun-test.d.ts
@@ -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.
@@ -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.