Dependabot doesn't touch the `mockServiceWorker.js` file that gets automatically updated by `npm install` which causes problem with "manual changes". We'll need to bump this manually at least for the time being.
Recently msw was bumped from 1.2.1 to 1.2.2 (https://github.com/RedHatInsights/image-builder-frontend/pull/1245). The version gets updated in `mockServiceWorker.js` upon running `npm ci`.
This PR changes the version as it wasn't a part of the original bump PR, but appears after every clean install.
This commit integrates Mock Service Worker into the browser. This will
allow us to use MSW to mock network requests at the API level from a
browser using the same MSW fixtures that we are currently using for our
testing. This means we will be able to have the same environment for
debugging, development, and testing if desired.
To develop using MSW, the developer will now use `npm run
stage-beta:msw`. The dev server will start as normal, but now any
request made that has a corresponding fixture will be intercepted and
the fixture used to generate the response.
This adds an MSW=TRUE environment variable to the run script. When this
environment variable is present, the dev webpack config will copy
mockServiceWorker.js into the build directory (/dist) using CopyPlugin
and will add some necessary headers to the dev server's responses using
DefinePlugin.