vitest: Browser mode hanging on blank white screen, failing to load vitest/utils

Describe the bug

When trying to run a test in browser mode (playwright) with a basic example next.js application, the browser window opens but hangs on a blank screen and fails to load vitest/utils in the background.

Screenshot 2023-04-03 at 21 17 38

Reproduction

Reproduction repository, based on vitest next.js example: https://github.com/ludwigbacklund/vitest-browser-bug-repro

Just run yarn test, it will open a browser window and hang on a white screen. Check the console/network log.

System Info

System:
    OS: macOS 13.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 774.77 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nodenv/versions/16.13.1/bin/node
    Yarn: 1.22.15 - ~/.nodenv/versions/16.13.1/bin/yarn
    npm: 8.1.2 - ~/.nodenv/versions/16.13.1/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
    Safari: 16.4
  npmPackages:
    @vitejs/plugin-react: latest => 3.1.0 
    @vitest/browser: ^0.29.8 => 0.29.8 
    vitest: latest => 0.29.8

Used Package Manager

yarn

Validations

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@ludwigbacklund can you try adding this to your Vite config file?

  optimizeDeps: {
    exclude: ['vitest/utils'],
    include: ['@vitest/utils', 'vitest/browser'],
  },

https://github.com/userquin/vitest-browser-vue (not working with Vite 4.3 beta 5, I need to review the dependencies)

imagen

It’s weird because it was resolved for me, I need to check it again soon. Thank you so much.