Skip to content

upgrading @vitest/browser completely breaks tests #7822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 tasks done
m-lyon opened this issue Apr 10, 2025 · 2 comments
Closed
6 tasks done

upgrading @vitest/browser completely breaks tests #7822

m-lyon opened this issue Apr 10, 2025 · 2 comments

Comments

@m-lyon
Copy link

m-lyon commented Apr 10, 2025

Describe the bug

I recently upgraded from vitest 2.x to 3.x, and in doing so updated @vitest/browser to 3.1.1 from 2.1.8. In doing so, this bumped the requirement for @testing-library/user-event from ^14.5.2 to ^14.6.1. This change in @testing-library/user-event has broken all of my (non browser mode) tests.

An example of an error is:

Error: Should not already be working.
 ❯ performSyncWorkOnRoot node_modules/react-dom/cjs/react-dom.development.js:26112:11
 ❯ flushSyncCallbacks node_modules/react-dom/cjs/react-dom.development.js:12042:22
 ❯ flushActQueue node_modules/react/cjs/react.development.js:2667:24
 ❯ act node_modules/react/cjs/react.development.js:2582:11
 ❯ node_modules/@testing-library/react/dist/act-compat.js:47:25
 ❯ node_modules/@testing-library/react/dist/pure.js:285:28
 ❯ cleanup node_modules/@testing-library/react/dist/pure.js:281:22
 ❯ src/features/recipeIngredient/components/__tests__/EditableIngredient.test.tsx:15:9
     13| describe('Dropdown Action Keyboard', () => {
     14|     afterEach(() => {
     15|         cleanup();
       |         ^
     16|     });
     17|     it('should not navigate below dropdown options', async () => {

and dialog in the @vitest/ui shows

Warning: Attempted to synchronously unmount a root while React was already rendering. React cannot finish unmounting the root until the current render has completed, which may lead to a race condition.

Reproduction

The errors can be recreated in this repository commit by running npm run test.

I've had an initial go at trying to recreate this bug on a stackblitz but wasn't able to. If this is not a minimal enough of an example I can spend some time trying to do that.

For reference, this commit is one where the tests are working, where only the @testing-library/user-event requirement has been changed.

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 18.30 GB / 31.25 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.19.0 - ~/.nvm/versions/node/v20.19.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.19.0/bin/npm
  Browsers:
    Chrome: 131.0.6778.85
  npmPackages:
    @vitest/browser: ^3.1.1 => 3.1.1 
    @vitest/ui: ^3.1.1 => 3.1.1 
    playwright: ^1.49.1 => 1.49.1 
    vite: ^6.2.5 => 6.2.5 
    vitest: ^3.1.1 => 3.1.1 
    vitest-browser-react: ^0.1.1 => 0.1.1 
    vitest-fetch-mock: ^0.4.5 => 0.4.5

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Apr 11, 2025

Yes, please try reducing the reproduction. From the description, I'm not sure how we see this as Vitest bug than @testing-library/user-event bug (or any testing-library family).

Copy link

Hello @m-lyon. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants