-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Labels
Description
Describe the bug
Using Yarn PnP and upgrading Vitest from 4.0.1 to 4.0.15 my tests started failing with:
Error: Invalid Chai property: toBeInTheDocument
Upon inspection, I was met with the following error in the logs:
12:55:28 PM [vite] Internal server error: Failed to resolve import "@vitest/runner" from ".yarn/__virtual__/@vitest-browser-virtual-969622421b/0/cache/@vitest-browser-npm-4.0.15-58aae56eaa-b74c1ab5b0.zip/node_modules/@vitest/browser/dist/expect-element.js?v=40852818". Does the file exist?
Plugin: vite:import-analysis
File: .yarn/__virtual__/@vitest-browser-virtual-969622421b/0/cache/@vitest-browser-npm-4.0.15-58aae56eaa-b74c1ab5b0.zip/node_modules/@vitest/browser/dist/expect-element.js?v=40852818: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...
I have tested a couple of versions. Here's a table showing where it works.
| Version | Works? |
|---|---|
| 4.0.1 | ✅ |
| 4.0.10 | ✅ |
| 4.0.11 | ✅ |
| 4.0.12 | ✅ |
| 4.0.13 | ✅ |
| 4.0.14 | ❌ |
| 4.0.15 | ❌ |
Direct cause appears to be #8813, and specifically this line that it has introduced:
| import { recordArtifact } from '@vitest/runner' |
Workaround consists of adding the following to .yarnrc.yml:
packageExtensions:
"@vitest/[email protected]":
dependencies:
"@vitest/runner": '4.0.15'
which confirms we have a "classic" problem of an undeclared dependency.
Reproduction
I believe I have provided sufficient information for this bug to be resolved. If I'm mistaken, please let me know!
System Info
System:
OS: macOS 26.1
CPU: (10) arm64 Apple M1 Max
Memory: 2.76 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.11.1 - /private/var/folders/9x/22rs089d2t31txstbb0vnl1r0000gp/T/xfs-5c8aa94c/node
Yarn: 4.10.3 - /private/var/folders/9x/22rs089d2t31txstbb0vnl1r0000gp/T/xfs-5c8aa94c/yarn
npm: 11.6.2 - /usr/local/bin/npm
Browsers:
Chrome: 142.0.7444.177
Firefox: 141.0.3
Safari: 26.1Used Package Manager
yarn
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.