-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Browser tests break when importing path-to-regexp@8 and mocking modules in React tests #6540
Comments
Vitest's browser mocking relies |
I am encountering same issue when using vitetest browser mode.
In my case I could not use any environment such jsdom due to poor support of selectors in querySelector API.
This code has no errors when I run in browser. |
@hi-ogawa, does that happen because MSW is not treated as ESM by Vite? Otherwise, why would Vite attempt to optimize CJS dependency? |
The issue might be a bit more complicated. Vitest configures vitest/packages/browser/src/node/plugin.ts Lines 204 to 205 in 5e6de27
However, when users have its own I thought users can explicitly do This was my observation so far and unfortunately I haven't found a way to make this setup work (or even workaround) yet. |
Describe the bug
Testing a component that imports latest
path-to-regexp
, and that also mocks some modules.This results in error:
Looking at the devtools, it seems like mock service worker is using an unintended version of
path-to-regexp
:Reproduction
pnpm install
pnpm test
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: