You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the following error when rendering via @testing-library/react's render().
A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:
await act(() => ...)
The test also fails:
Caused by: TestingLibraryElementError: Unable to find an element with the text: test. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
Reproduction:
See "Relevant code or config" above.
Adding an un-awaited act manually does not resolve the issue either:
@testing-library/react
version: 16.2.0@vitest/browser
Relevant code or config:
What you did:
I use
use(promise)
in components.What happened:
I get the following error when rendering via
@testing-library/react
'srender()
.The test also fails:
Reproduction:
See "Relevant code or config" above.
Adding an un-awaited
act
manually does not resolve the issue either:Problem description:
I should never get any act warnings when using
@testing-library/react
functions.Suggested solution:
As the warning explicitly advises, awaiting the
act
call fixes the warning/test:AFAICT, in React 19,
act
always returns a promise, so it may be best to alwaysawait
it.Fixing the issue would make
render
async, which may be a breaking change.https://github.com/testing-library/react-testing-library/blob/main/src/pure.js#L149
The text was updated successfully, but these errors were encountered: