Closed petecartwright closed 1 month ago
@petecartwright I can't seem to reproduce the problem you're explaining here.
I can just run npm run dev
and look around in the app without any problem.
Tagging @kettanaito (the creator/maintainer of MSW) to know if we would need to add the created public/mockServiceWorker.js
file or not
Hey, folks!
You need to run msw init
if you want to use MSW in the browser. To my best knowledge, this stack uses MSW primarily for third-party API mocking during integration testing, which runs in Node.js. Thus, there was never the need to generate the worker script via msw init
.
You can learn more about using MSW in the browser here: https://mswjs.io/docs/integrations/browser.
yep, I can't reproduce this now either. :thinking: :thinking: :thinking: I'm 95% sure I did with a new repo at the time I filed this, but ¯_(ツ)_/¯
I could have sworn I found was triggering the browser mocking at the time, but I sure don't see it now.
Sorry for the false alarm, closing this and the PR.
@kettanaito big fan of msw btw!
Have you experienced this bug with the latest version of the template?
yes
Steps to Reproduce
npm run dev
mockServiceWorker.js
Expected Behavior
Ideally there should be no 404s in the console
Actual Behavior
MSW requires users to run
npx msw init public --save
to create the service worker it uses for mocking. The defaultnpm run dev
runs with the mock server on, so msw checks for that file on some (most?) http requests.Adding instructions to run that command to the docs should cover this use case - I'll open a PR soon to do that for discussion.