Skip to content
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

Require a separate installation of MSW #7556

Open
4 tasks done
sheremet-va opened this issue Feb 24, 2025 · 1 comment
Open
4 tasks done

Require a separate installation of MSW #7556

sheremet-va opened this issue Feb 24, 2025 · 1 comment
Labels
enhancement: pending triage p2-to-be-discussed Enhancement under consideration (priority)

Comments

@sheremet-va
Copy link
Member

Clear and concise description of the problem

@vitest/browser always installs MSW even if module mocking is not used.

Suggested solution

Instead of always installing MSW, maybe we should throw an error on vi.mock and ask for an MSW installation.

Alternative

No response

Additional context

No response

Validations

@sheremet-va sheremet-va added enhancement: pending triage p2-to-be-discussed Enhancement under consideration (priority) labels Feb 24, 2025
@sheremet-va sheremet-va moved this to P2 - 4 in Team Board Feb 24, 2025
@julienmonnard
Copy link

Hello!
I was about to file an issue when I saw this one, so I'll add some extra context here 🙂

I think this is a good idea, not only for the reason mentioned in the description above, but also because it seems to conflict with other installs of msw, expecially when these are not the same version.

I'm currently using msw@2.2.14 fixed version, and every time I do an npm install, the mockServiceWorker.js generated by msw will be for the version defined in @vitest/browser (currently msw^2.7.3).

If I keep the one generated for 2.7.3, I will get issues in my tests, and if I keep the one generated for 2.2.14, I will get issues in my mocks 😅

I guess making msw a peer dependency (required or optional) could help solve this conflict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement: pending triage p2-to-be-discussed Enhancement under consideration (priority)
Projects
Status: P2 - 4
Development

No branches or pull requests

2 participants