Skip to content

Commit

Permalink
fix: add global test registry (#568)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bartlomieju authored and ry committed Aug 21, 2019
1 parent b5ded6c commit 4531fa8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion testing/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4531fa8

Please sign in to comment.