Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add global test registry #568

Merged
merged 2 commits into from Aug 21, 2019

Conversation

@bartlomieju
Copy link
Contributor

commented Aug 18, 2019

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.

~/src/deno_std> deno test -A
Found 79 matching test files.
Hello world!
running 0 tests

test result: OK. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (0.34ms)

A simple fix appears to be to add a global registry of all tests. It causes to register every test (even using test function from different version of standard lib) in the same global array that can be picked up by test runner.

That's just first iteration and we'll probably arrive at better solution before landing this PR.

CC @ry

testing/mod.ts Show resolved Hide resolved

@bartlomieju bartlomieju changed the title fix: add global test registry [do not merge] fix: add global test registry Aug 18, 2019

@bartlomieju

This comment has been minimized.

Copy link
Contributor Author

commented Aug 21, 2019

@ry do you want me to change anything else in this PR?

@@ -69,8 +69,29 @@ function print(txt: string, newline: boolean = true): void {
Deno.stdout.writeSync(encoder.encode(`${txt}`));
}

declare global {
interface Window {

This comment has been minimized.

Copy link
@ry

ry Aug 21, 2019

Contributor

Is it really necessary to declare this before hand?

This comment has been minimized.

Copy link
@bartlomieju

bartlomieju Aug 21, 2019

Author Contributor

Without it TS complains that __DENO_TEST_REGISTRY doesn't exist on Window:

error TS2339: Property '__DENO_TEST_REGISTRY' does not exist on type 'Window'.

► file:///Users/biwanczuk/dev/deno_std/testing/mod.ts:90:23

90   candidates = window.__DENO_TEST_REGISTRY as TestDefinition[];

I can add @ts-ignore but this solution is more idiomatic

This comment has been minimized.

Copy link
@ry

ry Aug 21, 2019

Contributor

Ok sounds good.

@ry
ry approved these changes Aug 21, 2019
Copy link
Contributor

left a comment

LGTM

@ry ry merged commit 4531fa8 into denoland:master Aug 21, 2019

5 checks passed

denoland.deno_std Build #20190818.2 succeeded
Details
denoland.deno_std (Linux) Linux succeeded
Details
denoland.deno_std (Mac) Mac succeeded
Details
denoland.deno_std (Windows) Windows succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@bartlomieju bartlomieju deleted the bartlomieju:fix-deno_test_no_tests_found branch Aug 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.