summaryrefslogtreecommitdiff
path: root/cli/dts/lib.deno.ns.d.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-11-23 14:57:51 +0100
committerGitHub <noreply@github.com>2021-11-23 14:57:51 +0100
commitd8afd5683857de83f3cc80c33322df3d65377210 (patch)
tree0ffb7f1e94994282aadc6f6c342a1884c19774ae /cli/dts/lib.deno.ns.d.ts
parentae34f8fa10f4daddde3d32cc63773d288253d4d4 (diff)
feat(test): Add more overloads for "Deno.test" (#12749)
This commit adds 4 more overloads to "Deno.test()" API. ``` // Deno.test(function testName() { }); export function test(fn: (t: TestContext) => void | Promise<void>): void; // Deno.test("test name", { only: true }, function() { }); export function test( name: string, options: Omit<TestDefinition, "name">, fn: (t: TestContext) => void | Promise<void>, ): void; // Deno.test({ name: "test name" }, function() { }); export function test( options: Omit<TestDefinition, "fn">, fn: (t: TestContext) => void | Promise<void>, ): void; // Deno.test({ only: true }, function testName() { }); export function test( options: Omit<TestDefinition, "fn" | "name">, fn: (t: TestContext) => void | Promise<void>, ): void; ```
Diffstat (limited to 'cli/dts/lib.deno.ns.d.ts')
-rw-r--r--cli/dts/lib.deno.ns.d.ts93
1 files changed, 91 insertions, 2 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 74aa334e2..4bc938ba1 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -315,11 +315,11 @@ declare namespace Deno {
* ```ts
* import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts";
*
- * Deno.test("My test description", ():void => {
+ * Deno.test("My test description", (): void => {
* assertEquals("hello", "hello");
* });
*
- * Deno.test("My async test description", async ():Promise<void> => {
+ * Deno.test("My async test description", async (): Promise<void> => {
* const decoder = new TextDecoder("utf-8");
* const data = await Deno.readFile("hello_world.txt");
* assertEquals(decoder.decode(data), "Hello world");
@@ -331,6 +331,95 @@ declare namespace Deno {
fn: (t: TestContext) => void | Promise<void>,
): void;
+ /** Register a test which will be run when `deno test` is used on the command
+ * line and the containing module looks like a test module.
+ * `fn` can be async if required. Declared function must have a name.
+ *
+ * ```ts
+ * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts";
+ *
+ * Deno.test(function myTestName(): void {
+ * assertEquals("hello", "hello");
+ * });
+ *
+ * Deno.test(async function myOtherTestName(): Promise<void> {
+ * const decoder = new TextDecoder("utf-8");
+ * const data = await Deno.readFile("hello_world.txt");
+ * assertEquals(decoder.decode(data), "Hello world");
+ * });
+ * ```
+ */
+ export function test(fn: (t: TestContext) => void | Promise<void>): void;
+
+ /** Register a test which will be run when `deno test` is used on the command
+ * line and the containing module looks like a test module.
+ * `fn` can be async if required.
+ *
+ * ```ts
+ * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts";
+ *
+ * Deno.test("My test description", { permissions: { read: true } }, (): void => {
+ * assertEquals("hello", "hello");
+ * });
+ *
+ * Deno.test("My async test description", { permissions: { read: false } }, async (): Promise<void> => {
+ * const decoder = new TextDecoder("utf-8");
+ * const data = await Deno.readFile("hello_world.txt");
+ * assertEquals(decoder.decode(data), "Hello world");
+ * });
+ * ```
+ */
+ export function test(
+ name: string,
+ options: Omit<TestDefinition, "fn" | "name">,
+ fn: (t: TestContext) => void | Promise<void>,
+ ): void;
+
+ /** Register a test which will be run when `deno test` is used on the command
+ * line and the containing module looks like a test module.
+ * `fn` can be async if required.
+ *
+ * ```ts
+ * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts";
+ *
+ * Deno.test({ name: "My test description", permissions: { read: true } }, (): void => {
+ * assertEquals("hello", "hello");
+ * });
+ *
+ * Deno.test({ name: "My async test description", permissions: { read: false } }, async (): Promise<void> => {
+ * const decoder = new TextDecoder("utf-8");
+ * const data = await Deno.readFile("hello_world.txt");
+ * assertEquals(decoder.decode(data), "Hello world");
+ * });
+ * ```
+ */
+ export function test(
+ options: Omit<TestDefinition, "fn">,
+ fn: (t: TestContext) => void | Promise<void>,
+ ): void;
+
+ /** Register a test which will be run when `deno test` is used on the command
+ * line and the containing module looks like a test module.
+ * `fn` can be async if required. Declared function must have a name.
+ *
+ * ```ts
+ * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts";
+ *
+ * Deno.test({ permissions: { read: true } }, function myTestName(): void {
+ * assertEquals("hello", "hello");
+ * });
+ *
+ * Deno.test({ permissions: { read: false } }, async function myOtherTestName(): Promise<void> {
+ * const decoder = new TextDecoder("utf-8");
+ * const data = await Deno.readFile("hello_world.txt");
+ * assertEquals(decoder.decode(data), "Hello world");
+ * });
+ * ```
+ */
+ export function test(
+ options: Omit<TestDefinition, "fn" | "name">,
+ fn: (t: TestContext) => void | Promise<void>,
+ ): void;
/** Exit the Deno process with optional exit code. If no exit code is supplied
* then Deno will exit with return code of 0.
*