summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-04-02 09:26:40 -0400
committerGitHub <noreply@github.com>2020-04-02 09:26:40 -0400
commitc738797944bc7e373b51a04e4332c98010135545 (patch)
treef7f91ebd13df71f125588c9261eba912f27ddc30 /cli/js
parentff0b32f81d4cdbae9fe868a16a8b19227d79c8b1 (diff)
feat: deno test --filter (#4570)
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/lib.deno.ns.d.ts2
-rw-r--r--cli/js/testing.ts16
-rwxr-xr-xcli/js/tests/unit_test_runner.ts4
3 files changed, 11 insertions, 11 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index 955a302a6..ff83e499d 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -120,7 +120,7 @@ declare namespace Deno {
failFast?: boolean;
/** String or RegExp used to filter test to run. Only test with names
* matching provided `String` or `RegExp` will be run. */
- only?: string | RegExp;
+ filter?: string | RegExp;
/** String or RegExp used to skip tests to run. Tests with names
* matching provided `String` or `RegExp` will not be run. */
skip?: string | RegExp;
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<TestMessage["end"] & {}> {
- const filterFn = createFilterFn(only, skip);
+ const filterFn = createFilterFn(filter, skip);
const testApi = new TestApi(TEST_REGISTRY, filterFn, failFast);
// @ts-ignore
diff --git a/cli/js/tests/unit_test_runner.ts b/cli/js/tests/unit_test_runner.ts
index 0232bb437..ed8b9dd80 100755
--- a/cli/js/tests/unit_test_runner.ts
+++ b/cli/js/tests/unit_test_runner.ts
@@ -68,7 +68,7 @@ async function workerRunnerMain(
// Execute tests
await Deno.runTests({
exitOnFail: false,
- only: filter,
+ filter,
reportToConsole: false,
onMessage: reportToConn.bind(null, conn),
});
@@ -296,7 +296,7 @@ async function main(): Promise<void> {
// Running tests matching current process permissions
await registerUnitTests();
- await Deno.runTests({ only: filter });
+ await Deno.runTests({ filter });
}
main();