diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-08-21 18:34:34 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-08-21 12:34:34 -0400 |
commit | a1a024a9f09f91aa3e7b73b4ff4407a57052b3e0 (patch) | |
tree | 18e008dd94d638444e10e0f53621bea34932540a /testing/mod.ts | |
parent | 122226a587536eb197366830233646c4bd4caf7a (diff) |
fix: add global test registry (denoland/deno_std#568)
After adding deno test command a new problem appeared.
If you try running deno test inside this repo test runner will find
80 test files but won't run any tests! This is caused by fact that
deno test uses tagged version of standard library which causes
test function available inside to repo to be different function that
test available in standard lib used by deno test.
Original: https://github.com/denoland/deno_std/commit/4531fa81597c346fd291c1d1a2063789369fb84d
Diffstat (limited to 'testing/mod.ts')
-rw-r--r-- | testing/mod.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/testing/mod.ts b/testing/mod.ts index d1ddb9c8c..51fa62cea 100644 --- a/testing/mod.ts +++ b/testing/mod.ts @@ -69,8 +69,29 @@ function print(txt: string, newline: boolean = true): void { Deno.stdout.writeSync(encoder.encode(`${txt}`)); } +declare global { + interface Window { + /** + * A global property to collect all registered test cases. + * + * It is required because user's code can import multiple versions + * of `testing` module. + * + * If test cases aren't registered in a globally shared + * object, then imports from different versions would register test cases + * to registry from it's respective version of `testing` module. + */ + __DENO_TEST_REGISTRY: TestDefinition[]; + } +} + +let candidates: TestDefinition[] = []; +if (window["__DENO_TEST_REGISTRY"]) { + candidates = window.__DENO_TEST_REGISTRY as TestDefinition[]; +} else { + window["__DENO_TEST_REGISTRY"] = candidates; +} let filterRegExp: RegExp | null; -const candidates: TestDefinition[] = []; let filtered = 0; // Must be called before any test() that needs to be filtered. |