From c738797944bc7e373b51a04e4332c98010135545 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 2 Apr 2020 09:26:40 -0400 Subject: feat: deno test --filter (#4570) --- cli/js/testing.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cli/js/testing.ts') diff --git a/cli/js/testing.ts b/cli/js/testing.ts index 5f1a62c63..5769495b2 100644 --- a/cli/js/testing.ts +++ b/cli/js/testing.ts @@ -270,17 +270,17 @@ class TestApi { } function createFilterFn( - only: undefined | string | RegExp, + filter: undefined | string | RegExp, skip: undefined | string | RegExp ): (def: TestDefinition) => boolean { return (def: TestDefinition): boolean => { let passes = true; - if (only) { - if (only instanceof RegExp) { - passes = passes && only.test(def.name); + if (filter) { + if (filter instanceof RegExp) { + passes = passes && filter.test(def.name); } else { - passes = passes && def.name.includes(only); + passes = passes && def.name.includes(filter); } } @@ -299,7 +299,7 @@ function createFilterFn( export interface RunTestsOptions { exitOnFail?: boolean; failFast?: boolean; - only?: string | RegExp; + filter?: string | RegExp; skip?: string | RegExp; disableLog?: boolean; reportToConsole?: boolean; @@ -309,13 +309,13 @@ export interface RunTestsOptions { export async function runTests({ exitOnFail = true, failFast = false, - only = undefined, + filter = undefined, skip = undefined, disableLog = false, reportToConsole: reportToConsole_ = true, onMessage = undefined, }: RunTestsOptions = {}): Promise { - const filterFn = createFilterFn(only, skip); + const filterFn = createFilterFn(filter, skip); const testApi = new TestApi(TEST_REGISTRY, filterFn, failFast); // @ts-ignore -- cgit v1.2.3