vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
13.01k stars 1.16k forks source link

Vitest v1.0.0-beta5 browser mode hangs in an infinite reload #4570

Closed nicojs closed 11 months ago

nicojs commented 11 months ago

Describe the bug

When running the beta-5 release of vitest in browser mode, you can get stuck in an infinite loop if you have an older version of pretty-format installed as sibling of vitest. See animated gif:

vitest-infinite-reload

Reproduction

mkdir foo && cd foo
npm init --yes
npm i -D vitest@beta @vitest/browser@beta playwright pretty-format@21
touch vitest.config.js
# import { defineConfig } from 'vitest/config';
# 
# export default defineConfig({
#   test: {
#     globals: true,
#     browser: {
#       enabled: true,
#       name: 'chromium',
#       provider: 'playwright',
#       headless: false,
#     },
#   },
# });

# Add an example project
npx vitest

Or download this zip: vitest-infinite-reload.zip

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
    Memory: 10.11 GB / 15.49 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.18.0/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
    pnpm: 8.9.2 - ~/.nvm/versions/node/v18.18.0/bin/pnpm
  Browsers:
    Chrome: 118.0.5993.117
  npmPackages:
    @vitest/browser: ^1.0.0-beta.5 => 1.0.0-beta.5
    vitest: ^1.0.0-beta.5 => 1.0.0-beta.5

Used Package Manager

npm

Validations

beamery-tomht commented 11 months ago

I'm getting this issue on all versions from beta.1 to beta.5 and have the latest version of "pretty-format" in my resolutions. Are you sure this is the cause?

↪ yarn why pretty-format                                                                                                                                                                                            3875ms ~ 16:23:41 ~ 28 Nov
yarn why v1.22.19
[1/4] 🤔  Why do we have the module "pretty-format"...?
[2/4] 🚚  Initialising dependency graph...
warning Resolution field "pretty-format@29.7.0" is incompatible with requested version "pretty-format@^27.0.2"
warning Resolution field "pretty-format@29.7.0" is incompatible with requested version "pretty-format@29.4.3"
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "pretty-format@29.7.0"
info Reasons this module exists
   - "_project_#@types#jest" depends on it
   - Hoisted from "_project_#@types#jest#pretty-format"
   - Hoisted from "_project_#jest-matcher-utils#pretty-format"
   - Hoisted from "_project_#lerna#@lerna#legacy-package-management#pretty-format"
   - Hoisted from "_project_#@testing-library#react#@testing-library#dom#pretty-format"
   - Hoisted from "_project_#jest-axe#jest-matcher-utils#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#pretty-format"
   - Hoisted from "_project_#jest-matcher-utils#jest-diff#pretty-format"
   - Hoisted from "_project_#@jacuzzi#vacancy#vitest#@vitest#snapshot#pretty-format"
   - Hoisted from "_project_#@jacuzzi#vacancy#vitest#@vitest#utils#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#jest-config#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#jest-message-util#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#jest-snapshot#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#jest-validate#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#jest-config#jest-circus#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#jest-runner#jest-leak-detector#pretty-format"
   - Hoisted from "_project_#jest#@jest#core#jest-config#jest-circus#jest-each#pretty-format"
info Disk size without dependencies: "188KB"
info Disk size with unique dependencies: "296KB"
info Disk size with transitive dependencies: "916KB"
info Number of shared dependencies: 5
✨  Done in 0.38s.

vitest-reloads

yarn workspace @scope/package vitest --browser.enabled --browser.name chrome
// package/vitest.config.ts
import { defineConfig } from 'vitest/config';

// eslint-disable-next-line import/no-default-export
export default defineConfig({
  test: {
    include: ['test/specs/path/some-spec.spec.{ts,tsx}'],
  },
});
sheremet-va commented 11 months ago

@beamery-tomht what about v1.0.0-beta.6?

beamery-tomht commented 11 months ago

Yes, just checked and still happening. I've reverted back to 0.34.6 as the bug with tests hanging sometimes is less of a blocker than the tests not working at all 😿