Closed
Description
@testing-library/user-event
version: 12.2.2
- Testing Framework and version: Jest 26.6.3
- DOM Environment: whatever default ships with Jest 26.6.3
Relevant code or config
beforeEach(() => {
userEvent.click(button.getByTestId('foobar'));
});
What you did:
Ran the test
What happened:
Warning: An update to Foobar inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at https://fb.me/react-wrap-tests-with-act
in Foobar
Reproduction repository:
Problem description:
We don't have this problem when clicking the same button inside the test itself. But in beforeEach, it flips out and demands that we wrap in act and await. Then the warning goes away.
Suggested solution:
Either fix it or document it in the description for userEvent.click.
Metadata
Metadata
Assignees
Labels
No labels