-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Describe the bug
I'm seeing an error being reported when running tests in the browser, this appears to be caused by a missing dependency:
Plugin: vite:import-analysis
File: /projectPath/node_modules/.pnpm/@vitest+browser@4.0.15_vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2__vitest@4.0.15/node_modules/@vitest/browser/dist/expect-element.js?v=779a201b:1:521
1 | ...port{server}from"vitest/browser";import{recordArtifact}from"@vitest/runner";function getAriaCheckedRoles(){return[...
| ^
2 | `)}function redent(_,K){return indentString(stripIndent(_),K)}function indentString(_,K){return _.replace(/^(?!\s*$)/...
3 | `)}}class UserInputElementTypeError extends GenericTypeError{constructor(_,K,q){super(`an HTMLElement or an SVGElemen...
at TransformPluginContext._formatLog (file:///projectPath/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:28998:43)
at TransformPluginContext.error (file:///projectPath/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:28995:14)
at normalizeUrl (file:///projectPath/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:27118:18)
at file:///projectPath/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:27176:32
at async Promise.all (index 4)
at TransformPluginContext.transform (file:///projectPath/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:27144:4)
at EnvironmentPluginContainer.transform (file:///projectPath/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:28796:14)
at loadAndTransform (file:///projectPath/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:22669:26)
✓ library (chromium) test/webgl/utils.test.js (10 tests) 1ms
✓ library (chromium) test/timebar/generator.test.js (15 tests) 190ms
3:38:02 PM [vite] Internal server error: Failed to resolve import "@vitest/runner" from "../../node_modules/.pnpm/@vitest+browser@4.0.15_vite@7.2.7_@types+node@24.10.1_terser@5.44.1_yaml@2.8.2__vitest@4.0.15/node_modules/@vitest/browser/dist/expect-element.js?v=779a201b". Does the file exist?
Looking at the package.json for @vitest/browser I note that "@vitest/runner": "4.0.15", is listed under devDependencies, but this is being used in @vitest/browser/dist/expect-element.js? Worth stating that the tests do actually run in spite of this...
Reproduction
Running tests in with either the provider @vitest/browser or @vitest/browser-preview seems to produce this issue. I tried creating a little demo project but that seemed to work, so I guess bringing in some particular matcher causes the issue.
System Info
System:
OS: macOS 15.7.2
CPU: (12) arm64 Apple M4 Pro
Memory: 308.17 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - /Users/jackbromley/.nvm/versions/node/v22.14.0/bin/node
Yarn: 1.22.22 - /Users/jackbromley/.nvm/versions/node/v22.14.0/bin/yarn
npm: 10.9.2 - /Users/jackbromley/.nvm/versions/node/v22.14.0/bin/npm
pnpm: 10.20.0 - /Users/jackbromley/.nvm/versions/node/v22.14.0/bin/pnpm
bun: 1.2.22 - /Users/jackbromley/.bun/bin/bun
Browsers:
Chrome: 143.0.7499.41
Chrome Canary: 145.0.7568.0
Edge: 143.0.3650.75
Firefox: 146.0
Safari: 18.6Used Package Manager
pnpm
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.