Repository navigation
Is wrapping with act now required? #906
|
I have updated to React 18 and now to see a lot of act warnings and have needed to manually wrap userEvent calls. This is also the first time we have updated to userEvent 14, so perhaps we are doing something wrong? I have tried using the convenience API and also a 'session' I have created a simple test case with attached screenshot and code - test 1 has no warnings, but tests 2 and 3 do:
|
Replies: 7 comments 5 replies
|
Some further explorations:
|
|
No, wrapping with
If
|
|
Thanks, since my last comment I have started with a fresh install which does not exhibit this act warning. I have a feeling we have some kind of package mismatch somewhere - we have a quite large Monorepo. |
|
What fixed it for us in our monorepo was to set the resolution in our root package.json: |
|
I had the same issue, and I found that the root cause is having multiple versions of Do a User event registers an internal wrapper named |
|
I had the same problem, and I found upgrading to @testing-library/react@14.0.0 resolved the issue. |
|
The fix for my case was described in the answer (which was taken from the docs)
So I just removed |



No, wrapping with
actis neither required nor recommended.@testing-library/reactmanipulates the configuration of the underlying@testing-library/domwhen you import it.@testing-library/user-eventuses that configuration.If
await user.anyAPI()yields anactwarning anduser.anyAPI(); await waitFor()does not, they might not use the same configuration i.e. not the same copy of@testing-library/dom.