-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
manually flush microtasks in afterEach #514
manually flush microtasks in afterEach #514
Conversation
This PR replaces calling async act() in afterEach, with a version that still flushes microtasks, but doesn't wrap with act(). Explanation: If there are any hanging microtasks, that means a test ran without asserting on a valid state. Any async portion that causes updates should be asserted on, or atleast resolved within the scope of a test. This PR should still fire missing act warnings for a test, but won't let it leak to the next one.
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.
I'd like a review from one other maintainer, but I think this is acceptable.
@all-contributors please add @LaurensBosscher code |
I've put up a pull request to add @LaurensBosscher! 🎉 |
🎉 This PR is included in version 9.3.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
I just upgraded to 9.3.1 and this is causing my test suite to log the following error: ERROR: true, 'This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.' Is this something I need to worry about? I'm running my tests in Chrome using Karma. |
This was the only change from v9.3.0 to v9.3.1, right? When I switch between those versions I get |
@donaldpipowitch Please open a new issue with a reproducible example. Without code it's hard to tell whether this is intended or not. |
This is the rebase of #440. I've squashed both commits into the original commit.
Original description: