diff --git a/README.md b/README.md index 17739a8..1f16ba1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Test Suite -[![version](https://img.shields.io/badge/release-0.15.0-success)](https://deno.land/x/test_suite@0.15.0) -[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/test_suite@0.15.0/mod.ts) +[![version](https://img.shields.io/badge/release-0.16.0-success)](https://deno.land/x/test_suite@0.16.0) +[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/test_suite@0.16.0/mod.ts) [![CI](https://github.com/udibo/test_suite/workflows/CI/badge.svg)](https://github.com/udibo/test_suite/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/udibo/test_suite/branch/main/graph/badge.svg?token=EFKGY72AAV)](https://codecov.io/gh/udibo/test_suite) [![license](https://img.shields.io/github/license/udibo/test_suite)](https://github.com/udibo/test_suite/blob/master/LICENSE) @@ -26,12 +26,12 @@ also be imported directly from GitHub using raw content URLs. ```ts // Import from Deno's third party module registry -import { describe, it } from "https://deno.land/x/test_suite@0.15.0/mod.ts"; +import { describe, it } from "https://deno.land/x/test_suite@0.16.0/mod.ts"; // Import from GitHub import { describe, it, -} from "https://raw.githubusercontent.com/udibo/test_suite/0.15.0/mod.ts"; +} from "https://raw.githubusercontent.com/udibo/test_suite/0.16.0/mod.ts"; ``` ## Usage @@ -54,7 +54,7 @@ except they are called before and after each individual test. Below are some examples of how to use `describe` and `it` in tests. See -[deno docs](https://doc.deno.land/https/deno.land/x/test_suite@0.15.0/mod.ts) +[deno docs](https://doc.deno.land/https/deno.land/x/test_suite@0.16.0/mod.ts) for more information. ### Nested test grouping @@ -67,13 +67,13 @@ import { beforeEach, describe, it, -} from "https://deno.land/x/test_suite@0.15.0/mod.ts"; +} from "https://deno.land/x/test_suite@0.16.0/mod.ts"; import { assertEquals } from "https://deno.land/std@0.133.0/testing/asserts.ts"; import { getUser, resetUsers, User, -} from "https://deno.land/x/test_suite@0.15.0/examples/user.ts"; +} from "https://deno.land/x/test_suite@0.16.0/examples/user.ts"; describe("user describe", () => { let user: User; @@ -131,13 +131,13 @@ test result: ok. 1 passed (5 steps); 0 failed; 0 ignored; 0 measured; 0 filtered The example below can be found [here](examples/user_flat_test.ts). ```ts -import { describe, it } from "https://deno.land/x/test_suite@0.15.0/mod.ts"; +import { describe, it } from "https://deno.land/x/test_suite@0.16.0/mod.ts"; import { assertEquals } from "https://deno.land/std@0.133.0/testing/asserts.ts"; import { getUser, resetUsers, User, -} from "https://deno.land/x/test_suite@0.15.0/examples/user.ts"; +} from "https://deno.land/x/test_suite@0.16.0/examples/user.ts"; interface UserContext { user: User; diff --git a/test_suite.ts b/test_suite.ts index 07f174b..ae3c844 100644 --- a/test_suite.ts +++ b/test_suite.ts @@ -188,14 +188,8 @@ export class TestSuiteInternal implements TestSuite { if (!suite.hasOnlyStep) { for (let i = 0; i < suite.steps.length; i++) { const step = suite.steps[i]!; - if (step instanceof TestSuiteInternal) { - if (!(step.hasOnlyStep || step.describe.only)) { - suite.steps.splice(i--, 1); - } - } else { - if (!step.only) { - suite.steps.splice(i--, 1); - } + if (!(step instanceof TestSuiteInternal) && !step.only) { + suite.steps.splice(i--, 1); } } suite.hasOnlyStep = true; @@ -224,16 +218,11 @@ export class TestSuiteInternal implements TestSuite { } } - let omit = false; - if (suite.hasOnlyStep) { - if (step instanceof TestSuiteInternal) { - if (!(step.hasOnlyStep || step.describe.only)) omit = true; - } else { - if (!step.only) omit = true; - } + if ( + !(suite.hasOnlyStep && !(step instanceof TestSuiteInternal) && !step.only) + ) { + suite.steps.push(step); } - - if (!omit) suite.steps.push(step); } /** This is used internally to add hooks to a test suite. */ @@ -260,7 +249,15 @@ export class TestSuiteInternal implements TestSuite { context: T, t: Deno.TestContext, ): Promise { + const hasOnly = suite.hasOnlyStep || suite.describe.only || false; for (const step of suite.steps) { + if ( + hasOnly && step instanceof TestSuiteInternal && + !(step.hasOnlyStep || step.describe.only || false) + ) { + continue; + } + const { name, fn,