-
-
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
Vitest crashing in Yarn PnP mode when using happy-dom or jsdom environment and Yarn workspaces #4413
Comments
Looks like this is a duplicate of #899 |
Shoot! It looks like one indeed. I hope however that the research, workarounds, and reproducible repo will come in handy. |
Similar issue here. Running tests using
I think this is due to the dynamic import inside |
This is because node‘s URL is overriden by jsdom URL |
Ok, so is there a fix or workaround? |
You can override URL in setup files: import { URL } from 'node:url'
globalThis.URL = URL This might break some JSDOM API. |
@sheremet-va Unfortunately this doesn't work. vitest crashes with the error before the setup files are executed. Additionally, it can't be added to the global setup or the vitest config. I don't quite understand why this hack is required since it works perfectly well if using the normal |
I guess it uses global URL which is overriden by jsdom and incompatible with "path" module (url parser was updated in Node bot so long ago) |
Contrary to what this ticket is about I have switched to packageExtensions:
local-pkg@*:
peerDependencies:
"happy-dom": "*"
|
I am getting the same error as #4413 (comment)
However this appears to only affect Using Yarn 4.0.2 with PNP. Vite 4.5.0 |
I am getting the same error as #4413 (comment)
Using Yarn 4.0.2 with PnP, Vite 5.0.0, Vitest 1.0.4, jsdom 23.0.1. Edit: |
I created a yarn pull request to resolve this: yarnpkg/berry#6030 Well, the fix addresses this: The issue appears to be that somewhere, A quick fix is to replace all occurrences of
|
In my case, it works on Node.js 20, but I encounter the same error on version 18
yarn 4.0.2, vite 5.0.10, vitest 1.0.2 |
Thrilled to confirm version 1.1.1 fixed this issue for me! |
I'm still having this issue with version 1.1.2. If I run at the monorepo root I still get
I upgraded from 0.34 which was the last version that was working for us. |
This error has nothing to do with this issue. Yarn uses a global URL which is replaced when using |
Ok, I can open another ticket then. We are using jsdom though. |
Describe the bug
When running a really basic test (irrelevant to reproduction), when using happy-dom or jsdom environment and Yarn workspaces, the following error appears:
I dug down the issue and actually caught it in
tinypool
catch
:And now we got somewhere:
I tracked down the issue to
ensurePackageInstalled
function, and here's the full trace that leads to the issue above:and further to:
antfu-collective/local-pkg#2
I worked around this issue by quickly patching
ensurePackageInstalled
:But this didn't make the error go away 🫠 Another issue causing the same
{ type: 'Unhandled Error', stacks: [] }
output appeared.I again tracked it down, this time to
importModule
call, also fromlocal-pkg
.When patched like so:
the tests went all green. PHEW!
Reproduction
vitest-pnp.zip
Unzip
What I found especially surprising is that without
submodule
thing, installing and callingvitest
on the root level, it doesn't break.System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: