From 20dad3659c60b61c9f5af5427ad61857593bf3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 5 Mar 2020 11:52:18 +0100 Subject: refactor: preliminary cleanup of Deno.runTests() (#4237) * refactor: preliminary cleanup of Deno.runTests() * Change time measurement to use new Date() instead of performance.now(). Because there is no guarantee that tests are run with "--allow-hr" using new Date() guarantees higher precision of 1ms instead of 2ms. * Support String type filter in "skip" and "only". * Split "exitOnFail" into "exitOnFail" and "failFast". Former tells if "runTests()" should exit with code 1 on test failure, while latter tells if "runTests()" should stop running tests on first failure. * Use "defer" to wait for unhandled promise rejection - this bit is funky and doesn't seem right, but for now it's just a rewrite from using "setTimeout". Intended to be fixed in later commits. * Remove global "__DENO_TEST_REGISTRY", don't expose list of registered tests (to be addressed in follow up commits) * Remove arbitrary slow test threshold; use uniform coloring instead --- cli/js/lib.deno.ns.d.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'cli/js/lib.deno.ns.d.ts') diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 9a339f3d2..555a2ebf7 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -33,15 +33,17 @@ declare namespace Deno { export function test(name: string, fn: TestFunction): void; export interface RunTestsOptions { - /** If `true`, Deno will exit upon a failure after logging that failure to - * the console. Defaults to `false`. */ + /** If `true`, Deno will exit with status code 1 if there was + * test failure. Defaults to `true`. */ exitOnFail?: boolean; - /** Provide a regular expression of which only tests that match the regular - * expression are run. */ - only?: RegExp; - /** Provide a regular expression of which tests that match the regular - * expression are skipped. */ - skip?: RegExp; + /** If `true`, Deno will exit upon first test failure Defaults to `false`. */ + 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; + /** String or RegExp used to skip tests to run. Tests with names + * matching provided `String` or `RegExp` will not be run. */ + skip?: string | RegExp; /** Disable logging of the results. Defaults to `false`. */ disableLog?: boolean; } -- cgit v1.2.3