-
Notifications
You must be signed in to change notification settings - Fork 1.1k
await act(...) inside cleanup-after-each #427
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
await act(...) inside cleanup-after-each #427
Conversation
I wonder how this would work with |
I think we would remove What if we do the breaking change release now and either document a workaround for the current version or release this as a non-recommended minor version on top of the current release? |
c98fcb8
to
563f333
Compare
Right, so don't even consider cleanupAsync as a public api right now? |
I updated the PR to do a dynamic require() in |
I could even just move the code into cleanup-after-each, and not have a new export at all |
I suspect these usages are just as common if not more so than
It's not a breaking change for the first one to return a promise though @kentcdodds maybe ask via the TestingLib twitter what people are using? |
563f333
to
85c221e
Compare
Yeah, I wish that people would just import the thing, but I suspect many are using cleanup directly 😔 I'll do a twitter poll for curiosity reasons, but I think we should leave this PR as-is, not document |
Alright, I updated the PR so it's only in |
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.
LGTM. What do you think @alexkrolick?
85c221e
to
75c3ee5
Compare
- awaits an `act(async () => {})` inside `cleanup-after-each` Some possible Q&A: - why not do the same in sync cleanup()?: if peeps are using react-testing-library already, it's suuuper unlikely they'll have hanging sync effects/updates. Decided not to add code without a good reason. (bonus: fixes a lint violation in act-compat.js)
75c3ee5
to
95504af
Compare
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.
🎸
Thanks Sunil! |
🎉 This PR is included in version 8.0.8 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
This PR adds an async
act()
call tocleanup-after-each
.Why:
Tests, especially those with async logic, could have hanging microtasks or React work that could leak into the next test.
How:
This PR
cleanup-async.js
(so I can write tests for it)act(async () => {})
call before unmounting containersSome possible Q&A:
act()
incleanup()
?: If peeps are using react-testing-library, it's suuuper unlikely they'll have hanging sync effects/updates. Decided not to add code without a good reason.(bonus: fixes a lint violation in act-compat.js)
Checklist: