Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Commit

Permalink
Upgrade Deno to 1.3.2 and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleJune committed Aug 29, 2020
1 parent f1a5b5a commit 1a1bf61
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/[email protected]/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/[email protected]/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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion deps/std/async/delay.ts
Original file line number Diff line number Diff line change
@@ -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";
2 changes: 1 addition & 1 deletion deps/std/testing/asserts.ts
Original file line number Diff line number Diff line change
@@ -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";
2 changes: 1 addition & 1 deletion deps/udibo/mock/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
6 changes: 3 additions & 3 deletions test_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class TestSuite<T> {
/** 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<T>;
/**
* The parent test suite that the test suite belongs to.
* Any option that is not specified will be inherited from the parent test suite.
Expand Down Expand Up @@ -223,11 +223,11 @@ export class TestSuite<T> {
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();
}
Expand Down
8 changes: 4 additions & 4 deletions test_suite_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>[] = [
spy((context: Context) => {
Expand Down Expand Up @@ -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<void>[] = [
spy((context: Context) => {
Expand Down Expand Up @@ -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<void>[] = [
spy((context: Context) => {
Expand Down Expand Up @@ -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<void>[] = [
spy((context: Context) => {
Expand Down

0 comments on commit 1a1bf61

Please sign in to comment.