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
Merged

fix: add global test registry #568

merged 2 commits into from
Aug 21, 2019

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju 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
Copy link
Member Author

@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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to declare this before hand?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sounds good.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit 4531fa8 into denoland:master Aug 21, 2019
@bartlomieju bartlomieju deleted the fix-deno_test_no_tests_found branch August 21, 2019 16:37
ry pushed a commit to ry/deno that referenced this pull request Oct 9, 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.
Original: denoland/std@4531fa8
inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants