From 1a1bf613f3ab03d463d24dd91ff7a94042ae37c2 Mon Sep 17 00:00:00 2001 From: Kyle June Date: Sat, 29 Aug 2020 18:03:40 -0500 Subject: [PATCH] Upgrade Deno to 1.3.2 and lint --- .github/workflows/ci.yml | 2 +- .vscode/launch.json | 23 +++++++++++++++++++++++ README.md | 16 ++++++++-------- deps/std/async/delay.ts | 2 +- deps/std/testing/asserts.ts | 2 +- deps/udibo/mock/mod.ts | 2 +- test_suite.ts | 6 +++--- test_suite_test.ts | 8 ++++---- 8 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7a389d..abcf1fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Install deno uses: denolib/setup-deno@master with: - deno-version: 1.3.1 + deno-version: 1.3.2 - name: Check formatting if: matrix.config.kind == 'lint' run: | diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..48fa83b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "deno run", + "type": "pwa-node", + "request": "launch", + "cwd": "${workspaceFolder}", + "runtimeExecutable": "deno", + "runtimeArgs": ["run", "--inspect-brk", "${file}"], + "attachSimplePort": 9229 + }, + { + "name": "deno test", + "type": "pwa-node", + "request": "launch", + "cwd": "${workspaceFolder}", + "runtimeExecutable": "deno", + "runtimeArgs": ["test", "--inspect-brk", "${file}"], + "attachSimplePort": 9229 + } + ] +} diff --git a/README.md b/README.md index 941a6b9..ab5a206 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Test Suite -[![version](https://img.shields.io/badge/release-v0.1.0-success)](https://github.com/udibo/test_suite/tree/v0.1.0) +[![version](https://img.shields.io/badge/release-v0.2.0-success)](https://github.com/udibo/test_suite/tree/v0.2.0) +[![deno doc](https://img.shields.io/badge/deno-doc-success?logo=deno)](https://doc.deno.land/https/deno.land/x/test_suite@v0.4.1/mod.ts) +[![deno version](https://img.shields.io/badge/deno-v1.3.2-success?logo=deno)](https://github.com/denoland/deno/tree/v1.3.2) [![CI](https://github.com/udibo/mock/workflows/CI/badge.svg)](https://github.com/udibo/test_suite/actions?query=workflow%3ACI) -[![deno version](https://img.shields.io/badge/deno-v1.3.1-success)](https://github.com/denoland/deno/tree/v1.3.1) -[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/test_suite@v0.1.0/mod.ts) [![license](https://img.shields.io/github/license/udibo/test_suite)](https://github.com/udibo/test_suite/blob/master/LICENSE) This module extends Deno's built-in test runner to add setup/teardown hooks @@ -23,16 +23,16 @@ but can also be imported directly from GitHub using raw content URLs. ```ts // Import from Deno's third party module registry -import { TestSuite, test } from "https://deno.land/x/test_suite@v0.1.0/mod.ts"; +import { TestSuite, test } from "https://deno.land/x/test_suite@v0.2.0/mod.ts"; // Import from GitHub -import { TestSuite, } "https://raw.githubusercontent.com/udibo/test_suite/v0.1.0/mod.ts"; +import { TestSuite, } "https://raw.githubusercontent.com/udibo/test_suite/v0.2.0/mod.ts"; ``` ## Usage Below are some examples of how to use TestSuite and test in tests. -See [deno docs](https://doc.deno.land/https/deno.land/x/test_suite@v0.1.0/mod.ts) for more information. +See [deno docs](https://doc.deno.land/https/deno.land/x/test_suite@v0.2.0/mod.ts) for more information. ### TestSuite @@ -47,8 +47,8 @@ The beforeEach and afterEach hook options are similar to beforeAll and afterAll The example test below can be found in the example directory. ```ts -import { TestSuite, test } from "https://deno.land/x/test_suite@v0.1.0/mod.ts"; -import { assertEquals } from "https://deno.land/std@0.66.0/testing/asserts.ts"; +import { TestSuite, test } from "https://deno.land/x/test_suite@v0.2.0/mod.ts"; +import { assertEquals } from "https://deno.land/std@0.67.0/testing/asserts.ts"; import { User, getUser, resetUsers } from "./example/user.ts"; interface UserSuiteContext { diff --git a/deps/std/async/delay.ts b/deps/std/async/delay.ts index 23c3abe..f9bcaac 100644 --- a/deps/std/async/delay.ts +++ b/deps/std/async/delay.ts @@ -1 +1 @@ -export { delay } from "https://deno.land/std@0.66.0/async/delay.ts"; +export { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; diff --git a/deps/std/testing/asserts.ts b/deps/std/testing/asserts.ts index 72edc5c..ac68135 100644 --- a/deps/std/testing/asserts.ts +++ b/deps/std/testing/asserts.ts @@ -1,3 +1,3 @@ export { assertEquals, -} from "https://deno.land/std@0.66.0/testing/asserts.ts"; +} from "https://deno.land/std@0.67.0/testing/asserts.ts"; diff --git a/deps/udibo/mock/mod.ts b/deps/udibo/mock/mod.ts index 8aabcb6..493859e 100644 --- a/deps/udibo/mock/mod.ts +++ b/deps/udibo/mock/mod.ts @@ -4,4 +4,4 @@ export { stub, Stub, SpyCall, -} from "https://deno.land/x/mock@v0.4.0/mod.ts"; +} from "https://deno.land/x/mock@v0.5.0/mod.ts"; diff --git a/test_suite.ts b/test_suite.ts index 2c28996..840071c 100644 --- a/test_suite.ts +++ b/test_suite.ts @@ -140,7 +140,7 @@ export class TestSuite { /** The name of the test suite will be prepended to the names of tests in the suite. */ private name: string; /** The context for tests within the suite. */ - private context: T; + private context: Partial; /** * The parent test suite that the test suite belongs to. * Any option that is not specified will be inherited from the parent test suite. @@ -223,11 +223,11 @@ export class TestSuite { await this.suite.beforeAll(); this.context = { ...this.suite.context, ...this.context }; } - if (options.beforeAll) await options.beforeAll(this.context); + if (options.beforeAll) await options.beforeAll(this.context as T); this.started = true; }; this.afterAll = async () => { - if (options.afterAll) await options.afterAll(this.context); + if (options.afterAll) await options.afterAll(this.context as T); if (this.suite && this.suite.last === this.last) { await this.suite.afterAll(); } diff --git a/test_suite_test.ts b/test_suite_test.ts index 4e1fb2a..6ce1e16 100644 --- a/test_suite_test.ts +++ b/test_suite_test.ts @@ -409,7 +409,7 @@ Deno.test("top level suite test hooks single context empty", async () => { assertEquals(beforeAllHook.calls.length, 1); assertEquals(beforeEachHook.calls.length, 2); assertEquals(afterEachHook.calls.length, 2); - delete context.a; + context.a = 0; }); const testSpys: Spy[] = [ spy((context: Context) => { @@ -520,7 +520,7 @@ Deno.test("top level suite test hooks single context populated", async () => { assertEquals(beforeAllHook.calls.length, 1); assertEquals(beforeEachHook.calls.length, 2); assertEquals(afterEachHook.calls.length, 2); - delete context.a; + context.a = 0; }); const testSpys: Spy[] = [ spy((context: Context) => { @@ -635,7 +635,7 @@ Deno.test("top level suite test async hooks single context empty", async () => { assertEquals(beforeEachHook.calls.length, 2); assertEquals(afterEachHook.calls.length, 2); await delay(1); - delete context.a; + context.a = 0; }); const testSpys: Spy[] = [ spy((context: Context) => { @@ -750,7 +750,7 @@ Deno.test("top level suite test async hooks single context populated", async () assertEquals(beforeEachHook.calls.length, 2); assertEquals(afterEachHook.calls.length, 2); await delay(1); - delete context.a; + context.a = 0; }); const testSpys: Spy[] = [ spy((context: Context) => {