-
Notifications
You must be signed in to change notification settings - Fork 3
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
Components which suspend do not resolve suspense when tested #9
Comments
I am OK with changing the API. @MatanBobi what do you think? |
It's reasonable to me, we have an effort for that in RTL: testing-library/react-testing-library#1214 but it's been open for a while now. I believe that the main concern is that since we're not wrapping interactions here with |
Vitest triggers a native click, so it should work the same way it works in production. To catch the changes in DOM, users should call |
So I believe that this change will happen sooner or later in RTL too so I'm all in on changing it here too. |
Reproduction repo here: https://github.com/a-type/vitest-browser-react-suspense-repro
I have a component which suspends on render until a certain promise is fulfilled (I'm using the new React 19
use
, but I believe this behavior is consistent without React 19, for example using the oldersuspend-react
library).When I render this component in a test (wrapping it with a Suspense boundary), it never updates. I can see that the promise is resolved via the test log, but the rendered output remains in the suspended state.
If I run a normal Vite app with the same component, I can see that after the appropriate time, the suspense is resolved and the component contents are displayed.
Additional logs from the test are probably relevant:
I manually patched the vitest-browser-react module to await
act
on initial render and it appears to have resolved the problem. However, this changes the API, requiringrender
to be an async function and awaited by the user.The text was updated successfully, but these errors were encountered: