Testing · Middle · Question 2 of 75
What is wrong with this waitFor?
await waitFor(async () => {
await user.click(screen.getByRole("button", { name: "Save" }));
expect(screen.getByText("Saved")).toBeInTheDocument();
});- ✓Correct answer: Side effects inside
waitForrepeat on every retry - click once outside, then wait only for the assertion - 2
waitFordoesn't accept async callbacks - 3Nothing - it's the recommended way
Explanation
The callback may run many times, so it should contain only assertions, ideally a single one.