summaryrefslogtreecommitdiff
path: root/cli/tests/unit/test_util.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-06-12 16:58:04 +0100
committerGitHub <noreply@github.com>2020-06-12 11:58:04 -0400
commite613bfe47a3ebec076c82d038738904114ff2a7c (patch)
treec9deee488fc8dd3bf7fdcdd65be1f8677307a1d0 /cli/tests/unit/test_util.ts
parent3eee9614732ed8636bb8ebbd6f6a13d44531df6c (diff)
feat: Add TestDefinition::only (#5793)
Diffstat (limited to 'cli/tests/unit/test_util.ts')
-rw-r--r--cli/tests/unit/test_util.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/cli/tests/unit/test_util.ts b/cli/tests/unit/test_util.ts
index 660e13511..25da7a638 100644
--- a/cli/tests/unit/test_util.ts
+++ b/cli/tests/unit/test_util.ts
@@ -1,6 +1,8 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "../../../std/testing/asserts.ts";
+import * as colors from "../../../std/fmt/colors.ts";
+export { colors };
import { resolve } from "../../../std/path/mod.ts";
export {
assert,
@@ -93,7 +95,9 @@ function registerPermCombination(perms: Permissions): void {
export async function registerUnitTests(): Promise<void> {
const processPerms = await getProcessPermissions();
- for (const unitTestDefinition of REGISTERED_UNIT_TESTS) {
+ const onlyTests = REGISTERED_UNIT_TESTS.filter(({ only }) => only);
+ const unitTests = onlyTests.length > 0 ? onlyTests : REGISTERED_UNIT_TESTS;
+ for (const unitTestDefinition of unitTests) {
if (!permissionsMatch(processPerms, unitTestDefinition.perms)) {
continue;
}
@@ -126,11 +130,13 @@ interface UnitTestPermissions {
interface UnitTestOptions {
ignore?: boolean;
+ only?: boolean;
perms?: UnitTestPermissions;
}
interface UnitTestDefinition extends Deno.TestDefinition {
ignore: boolean;
+ only: boolean;
perms: Permissions;
}
@@ -174,6 +180,7 @@ export function unitTest(
name,
fn,
ignore: !!options.ignore,
+ only: !!options.only,
perms: normalizedPerms,
};