Open
Description
What you did:
A simple update from v13 to v14 broke my Vitest-based test where I was using await user.click(...)
as the promise no longer resolves.
Reproduction:
Run repo at the following commit: wojtekmaj/react-async-button@fa41b3b
Suggested solution:
After long debug session, I have determined that
- Monkey patching
asyncWrapper
to be justcb => cb()
resolves the issue. - Removing the following code added in fix: Prevent "missing act" warning for queued microtasks #1137 resolves the issue:
react-testing-library/src/pure.js
Lines 41 to 52 in f78839b
- Moving
if (jestFakeTimersAreEnabled()) { ... }
to wrap the entire block mentioned above resolves the issue. - Calling
vi.advanceTimersByTime(0);
manually afteruser.click(...)
but beforeawait
ing returned promise, even multiple times, does NOT help - The only workaround that worked for me was this: wojtekmaj/react-async-button@2d26f21
So my suggestion is to:
- Roll back the fix and perhaps reintroduce when advanceTimers will be configurable and not jest dependent
- OR move
if (jestFakeTimersAreEnabled()) { ... }
to wrap the entire block mentioned above, acknowledging that the fix is now Jest-only.