fix(fireEvent): automatically configure fireEvent
to be wrapped in act
#685
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
fireEvent
to 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
fireEvent
will be globally configured to be wrapped inact
so 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.js
is 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.js
actually pure.How:
Checklist:
act
was called correctly is still passing)Now not only will React Testing Library's
fireEvent
be wrapped inact
, but so will DOM Testing Library'sfireEvent
(if@testing-library/react
is imported). It works very similar to asyncact 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