-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
Preface: thank you for all of your hard work; Browser Mode with the preview provider is the reason I strongly favor vitest for my project. I need the speed of Jest, the runtime inspectability of Cypress or Playwright, and the clean architectural simplicity of vite -- and you are poised to deliver! ❤️
When I write a trivial test for a trivial component and try to run vitest, nothing works. It seems something is going very wrong with module paths on disk and/or contents, as represented in the bundled code which makes it into the browser. Perhaps the test server is being influenced by a bad configuration choice in one of my vite/tsconfig files?
The first telltale happens when I open the runner:
$ npx vitest
DEV v2.0.0-beta.12 <basedir>
Browser runner started at http://localhost:5173/
Sourcemap for "<basedir>/node_modules/@vitest/browser/dist/client/__vitest_browser__/client-Dz5Ebwug.js" points to missing source files
Sourcemap for "<basedir>/node_modules/vitest/dist/runners.js" points to missing source files
Sourcemap for "<basedir>/node_modules/vitest/dist/vendor/setup-common.CWnv_2-5.js" points to missing source files
Sourcemap for "<basedir>/node_modules/@vitest/snapshot/dist/index.js" points to missing source files
My favored browser (Chrome) opens and happily shows the vitest UI, but my test is stuck in "pending" forever:
Opening the browser console reveals more errors:
Uncaught SyntaxError: The requested module '/node_modules/@vitest/runner/node_modules/pretty-format/build/index.js?v=3e2658e0' does not provide an export named 'format' (at chunk-display.js:1:10)
Uncaught TypeError: __vitest_browser_runner__.runTests is not a function
at <basedir>/src/atoms/__tests__/button.test.tsx:86:27
Reproduction
I've created a public repository with a minimal reproduction.
Just clone, npm install, and npx vitest.
System Info
System:
OS: macOS 14.5
CPU: (12) arm64 Apple M3 Pro
Memory: 1.35 GB / 36.00 GB
Shell: 3.7.0 - /opt/homebrew/bin/fish
Binaries:
Node: 20.11.0 - ~/.asdf/installs/nodejs/20.11.0/bin/node
Yarn: 1.22.22 - ~/.asdf/installs/nodejs/20.11.0/bin/yarn
npm: 10.8.1 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 9.1.1 - ~/.asdf/installs/nodejs/20.11.0/bin/pnpm
Browsers:
Chrome: 126.0.6478.127
Safari: 17.5
npmPackages:
@vitejs/plugin-react: ^4.2.1 => 4.2.1
@vitest/browser: ^2.0.0-beta.12 => 2.0.0-beta.12
vite: ^5.2.0 => 5.2.7
vitest: ^2.0.0-beta.12 => 2.0.0-beta.12Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.