-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snapshot Error with Yarn PnP in Workspace Using setupFiles #6887
Comments
I'm not familiar with pnp, but wouldn't Vitest having two way peer dep is not a good thing, but we haven't figured out how to avoid that. Btw, I think we also have an issue with |
Thank you for checking! However, Yarn provides a way to manually fix ghost dependencies, and I tried that, but the problem persists. |
Hmm, interesting, I thought they had optional peer dep at some point. FWIW, downgrading |
@hi-ogawa |
I am also using pnpm workspace and got the same error. By downgrading |
Describe the bug
In the following reproduction, running this script works without any errors:
yarn test
However, the following command throws an unexpected error:
yarn workspace sample test
If I comment out
packages/sample/vitest.setup.js
, thenyarn workspace sample test
runs without errors.Additional Context
Upon further investigation, I found similar issues mentioned in #3426, but this problem occurs even though all peer dependencies of Vitest are the same in both the root and the workspace.
Here's the result of
yarn why vitest
(you can try this yourself on CodeSandbox):It seems like two different virtual folders are created for Vitest, even though all peer dependencies are installed identically. I suspect the issue might be caused by
@vitest/ui
, which listsvitest
as a peer dependency, and vice versa (vitest
also has@vitest/ui
as a peer dependency).If I remove
@vitest/ui
from both the root and the workspace, then the virtual folders forvitest
are unified, and the issue is resolved.In conclusion, this issue might be fixed if the common logic shared between
vitest
and@vitest/ui
is extracted into a separate independent package, which bothvitest
and@vitest/ui
can depend on.I’m still not sure why the issue is resolved when I comment out the code specified in
setupFiles
. By tracing the error stack, I found that whensetupFiles
is used, the snapshot client instance is created using the rootvitest
, but during the actual test, it attempts to access the snapshot client instance from the workspace’svitest
(just like described in #3426).Reproduction
(had to use codesandbox instead to use yarn berry)
https://codesandbox.io/p/devbox/yarn-pnp-issue-4tx7yh
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: