-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest-circus: throw if a test / hook is defined asynchronously #8096
Conversation
cc @aaronabramov since this touches circus |
packages/jest-circus/src/types.ts
Outdated
@@ -183,6 +183,7 @@ export type State = { | |||
currentlyRunningTest: TestEntry | undefined | null; // including when hooks are being executed | |||
expand?: boolean; // expand error messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not for this PR, but we should use tsdoc for these so they show up when using autocomplete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you!
Needs to make the test non-flaky and add a changelog entry 🙂
Not sure if this is a fix or feature for the changelog 🤔 |
ergh... fix I'd say. It might have been working by accident before, and probably flaky depending on how much resources your computer had. So it's just an explicit error in the case of user error |
|
Apparently defining hooks in tests is supported? #6098 |
@mjesun @rubennorte did you ever manage to migrate away from those funky tests? |
@scotthovestadt perhaps you could also answer this using fbcodesearch or whatever it's called? |
32d2e5d
to
c559c75
Compare
Rebase this? |
@SimenB done. But we still need @scotthovestadt to verify that FB no longer has these weird hook definitions that would break because of this. Or would you do that when releasing an alpha an this has already landed anyway, instead of from this branch while it's open? |
Whatever's most convenient for @scotthovestadt 🙂 |
GitHub not realizing I've pushed the rebase ... https://www.githubstatus.com "Degraded Performance" |
(And ofc would have to remove beforeEachQueue e2e test that fails on circus once we think that weird behavior no longer needs to be supported before merging ) |
c559c75
to
2a2fb98
Compare
@scotthovestadt could you test this? |
No, this is a good change (y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This fixes the behavior when defining tests / hooks asynchronously in jest-circus.
Previously outside of a describe block (in the root describe block) the tests would be accepted and run.
Previously inside a describe block this error would be thrown:
But it was also possible to time it so that the test declared asynchronously in the describe block would become a test of the root describe block.
With this PR async definitions anywhere will throw:
Test plan
circus-only e2e test added