summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing/mod.ts21
-rw-r--r--testing/test.ts5
2 files changed, 23 insertions, 3 deletions
diff --git a/testing/mod.ts b/testing/mod.ts
index 462c13fb1..fa6fda246 100644
--- a/testing/mod.ts
+++ b/testing/mod.ts
@@ -86,9 +86,24 @@ function filter(name: string): boolean {
}
}
-export function test(t: TestDefinition | TestFunction): void {
- const fn: TestFunction = typeof t === "function" ? t : t.fn;
- const name: string = t.name;
+export function test(t: TestDefinition): void;
+export function test(fn: TestFunction): void;
+export function test(name: string, fn: TestFunction): void;
+export function test(
+ t: string | TestDefinition | TestFunction,
+ fn?: TestFunction
+): void {
+ let name: string;
+
+ if (typeof t === "string") {
+ if (!fn) {
+ throw new Error("Missing test function");
+ }
+ name = t;
+ } else {
+ fn = typeof t === "function" ? t : t.fn;
+ name = t.name;
+ }
if (!name) {
throw new Error("Test function may not be anonymous");
diff --git a/testing/test.ts b/testing/test.ts
index 8c86791ba..3a35be1e9 100644
--- a/testing/test.ts
+++ b/testing/test.ts
@@ -263,4 +263,9 @@ test(async function testingThrowsAsyncMsgNotIncludes(): Promise<void> {
assert(didThrow);
});
+test("test fn overloading", (): void => {
+ // just verifying that you can use this test definition syntax
+ assert(true);
+});
+
runIfMain(import.meta);