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.
kentcdodds
left a comment
There was a problem hiding this comment.
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: