Reproduction example
https://github.com/mikaelrss/rhf-rtl-act-bug-repro
Prerequisites
git clone [email protected]:mikaelrss/rhf-rtl-act-bug-repro.git
cd rhf-act-bug-repro
yarn install
yarn test --> See that the tests pass without any act warnings.
git checkout user-event@14
yarn install
yarn test --> See that the tests pass but now with an act warning.
Expected behavior
I expect that the test below passes without any act warnings.
it("should show an error message when title field is cleared", async () => {
render(<Form />);
expect(screen.queryByText("Title is required")).not.toBeInTheDocument();
await userEvent.clear(screen.getByLabelText("Title"));
expect(await screen.findByText("Title is required")).toBeInTheDocument();
});
Actual behavior
The following test produces an act warning.
it("should show an error message when title field is cleared", async () => {
render(<Form />);
expect(screen.queryByText("Title is required")).not.toBeInTheDocument();
await userEvent.clear(screen.getByLabelText("Title"));
expect(await screen.findByText("Title is required")).toBeInTheDocument();
});
Wrapping the await userEvent.clear(screen.getByLabelText("Title")) in an act removes the warning.
it("should show an error message when title field is cleared", async () => {
render(<Form />);
expect(screen.queryByText("Title is required")).not.toBeInTheDocument();
await act(async () => {
await userEvent.clear(screen.getByLabelText("Title"));
});
expect(await screen.findByText("Title is required")).toBeInTheDocument();
});
This works as expected with @testing-library/[email protected] but breaks in @testing-library/[email protected]
User-event version
14.1.1
Environment
Testing Library framework: @testing-library/[email protected]
JS framework: [email protected] and [email protected]
Test environment: [email protected] which uses [email protected]
Additional context
Working version on main branch of repro is @testing-library/[email protected]
Reproduction example
https://github.com/mikaelrss/rhf-rtl-act-bug-repro
Prerequisites
git clone [email protected]:mikaelrss/rhf-rtl-act-bug-repro.gitcd rhf-act-bug-reproyarn installyarn test--> See that the tests pass without any act warnings.git checkout user-event@14yarn installyarn test--> See that the tests pass but now with an act warning.Expected behavior
I expect that the test below passes without any act warnings.
Actual behavior
The following test produces an act warning.
Wrapping the
await userEvent.clear(screen.getByLabelText("Title"))in anactremoves the warning.This works as expected with
@testing-library/[email protected]but breaks in@testing-library/[email protected]User-event version
14.1.1
Environment
Testing Library framework:
@testing-library/[email protected]JS framework:
[email protected]and[email protected]Test environment:
[email protected]which uses[email protected]Additional context
Working version on
mainbranch of repro is@testing-library/[email protected]