You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I comment out packages/sample/vitest.setup.js, then yarn 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 lists vitest 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 for vitest 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 both vitest 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 when setupFiles is used, the snapshot client instance is created using the root vitest, but during the actual test, it attempts to access the snapshot client instance from the workspace’s vitest (just like described in #3426).
Reproduction
(had to use codesandbox instead to use yarn berry)
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 @vitest/browser too.
Thank you for checking!
Yes, @testing-library/jest-dom has ghost dependency issues. Upon checking, it seems like it was initially declared as a peer dependency but was later removed (I'm not entirely sure why this decision was made).
Hmm, interesting, I thought they had optional peer dep at some point. FWIW, downgrading 6.4.7 seems to work, which is right before they remove peer dep.
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: