-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Vitest is not showing act warnings when it actually should when testing React components #6782
Comments
There is zero code except "it" from your reproduction that is coming from Vitest. Vitest doesn't know anything about react, the testing library that you use renders your components, not Vitest. |
Hmmm, running the exact same test and only removing the vitest I'm not using anything from RTL except for the render and the getByText methods which does not do contribute to the issue as the real issue comes when clicking the button (because it sets a state in async) |
The testing library might rely in jest API to give the warnings. Vitest does nothing but give a runtime to run the code in. This is an issue with testing-library running in Vitest, not Vitest doing something different. |
@sheremet-va
No more RTL here. Jest still shows act warnings |
Then react itself expects a jest environment to give act warnings. Again, there is nothing Vitest does to make this work/not work. |
I see, that is a reasonable explanation. Will take this to the React team cause I really think this is a blocking issue, act warnings should be always displayed regardless of the test runner (jest or vitest in this case). I'll come back with their replies (hopefully soon) Thank you for the very quick reply btw, great project! |
Look like you can use |
Describe the bug
Act warnings are very useful to spot issues in your codebase and to make tests more resilient.
I have a test that should trigger an act warning. When trying to run Jest and rendering the component it shows the act warnings as expected but when running vitest no act warnings are shown, I tried playing around with configuration file to see if console warnings/errors are disabled somehow but no luck.
If vitest does some act wrapping magic then it should document it some where, act warnings in general are very useful and makes 1) tests more resiliant 2) spot issues in your code.
Here is the component I'm testing:
Here is the test:
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-zk9hnz?file=test%2Fcounter.test.tsx
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: