fix(fireEvent): automatically configure fireEvent to be wrapped in act#685
Merged
Conversation
Now not only will React Testing Library's `fireEvent` be wrapped in `act`, but so will DOM Testing Library's `fireEvent` (if `@testing-library/react` is imported). It works very similar to async act for the `asyncWrapper` config. Closes: testing-library/user-event#188 Closes: testing-library/user-event#255 Reference: https://github.com/testing-library/user-event/issues/277
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1e2e113:
|
kentcdodds
force-pushed
the
pr/fire-event-act
branch
from
June 1, 2020 23:29
bccc220 to
1e2e113
Compare
Codecov Report
@@ Coverage Diff @@
## master #685 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 4 +1
Lines 101 99 -2
Branches 15 15
=========================================
- Hits 101 99 -2
Continue to review full report at Codecov.
|
Member
Author
|
🎉 This PR is included in version 10.0.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
3 tasks
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: fix(fireEvent): automatically configure
fireEventto be wrapped in actWhy: Because now we don't have to do this nonsense:
react-testing-library/src/pure.js
Lines 107 to 128 in 0afcbea
It also means that
fireEventwill be globally configured to be wrapped inactso even if people import the DOM Testing Library one (like we do in@testing-libary/user-event), it will be wrapped in act (assuming they've also imported@testing-library/react).One note is that
pure.jsis not actually pure and never was because it configures DOM Testing Library globally. Perhaps in the future we should make a breaking change to makepure.jsactually pure.How:
Checklist:
actwas called correctly is still passing)Now not only will React Testing Library's
fireEventbe wrapped inact, but so will DOM Testing Library'sfireEvent(if@testing-library/reactis imported). It works very similar to asyncact for the
asyncWrapperconfig.Closes: testing-library/user-event#188
Closes: testing-library/user-event#255
Reference: https://github.com/testing-library/user-event/issues/277