testing-library / testing-library/react-testing-library

Update to v14 breaks @testing-library/user-event on Vitest

Open
#1,197 33 comments 51 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs more information
Dominant language
JavaScript
Stars
19.7k
Forks
1.2k
Avg merge
3d 16h
Merged PRs (30d)
1

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: https://github.com/wojtekmaj/react-async-button/commit/fa41b3b9900a25d76141bcf2080f94f7ee5f5dee

Suggested solution:

After long debug session, I have determined that

  • Monkey patching asyncWrapper to be just cb => cb() resolves the issue.
  • Removing the following code added in testing-library/react-testing-library#1137 resolves the issue:

https://github.com/testing-library/react-testing-library/blob/f78839bf4147a777a823e33a429bcf5de9562f9e/src/pure.js#L41-L52

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the reproduction at commit fa41b3b9900a25d76141bcf2080f94f7ee5f5dee and inspect src/pure.js, especially the block linked at lines 41-52. Compare the v13 and v14 user-event behavior under Vitest, then verify that awaiting user.click(...) resolves without relying only on Jest-specific timer handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.