Closed
Description
@testing-library/react
version: 14.0.0- Testing Framework and version: jest 29.4.2
- DOM Environment: @testing-library/jest-dom: 5.16.5
Relevant code or config:
const saveButton = screen.getByRole('button', { name: /save/i });
await waitFor(() => expect(saveButton).toBeEnabled());
await testUser.click(saveButton);
What you did:
I upgraded the version of @testing-library/react from 13.4.0 to 14.0.0. And I started having problems in all the tests of my application. Before this update this did not happen.
What happened:
I'm getting more act warnings now with @testing-library@14.0.0.
Tested with await waitFor, and still throwing act warnings with userEvent that triggers a state change.
Reproduction:
You can fork to reproduce the issue:
here: https://codesandbox.io/s/act-warning-wait-for-react-18-forked-6jurf2
Problem description:
The state update (setState()) seems to make the test library think that act is incomplete, even though it is. This happens for every unit test where an event is fired, such as userEvent.click() or userEvent.upload().
Metadata
Metadata
Assignees
Labels
No labels