-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Upgrade MSW from 1.3.5 to 2.12.4 #21096
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request upgrades Mock Service Worker (MSW) from version 1.3.5 to 2.12.4, involving a comprehensive migration from MSW v1 to v2 API patterns. The migration includes updating 113 handler files to use the new http namespace instead of rest, changing response construction from res(ctx.*) to HttpResponse constructors, and modifying handler signatures from (req, res, ctx) to destructured parameters ({ request, params }). The PR also updates the test infrastructure to ensure MSW is properly initialized before tests run.
Key Changes
- Updated MSW package dependency from ^1.3.5 to ^2.12.4
- Migrated 113+ handler files from MSW v1 to v2 API syntax
- Regenerated mockServiceWorker.js with v2 implementation
- Updated test runner configuration to load MSW sequentially with await
- Modified type imports to use v2 module paths (msw/browser)
Reviewed changes
Copilot reviewed 120 out of 121 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | MSW version bump from 1.3.5 to 2.12.4 |
| public/mockServiceWorker.js | Regenerated service worker with v2 implementation |
| web-test-runner.index.ts | Added await to worker.start() call |
| web-test-runner.config.mjs | Sequential async module loading to ensure MSW ready before tests |
| src/mocks/index.ts | Updated type imports to msw/browser and msw modules |
| src/mocks/handlers/**/*.handlers.ts | Migrated from rest to http namespace, updated response patterns |
Files not reviewed (1)
- src/Umbraco.Web.UI.Client/package-lock.json: Language not supported
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://victorious-ground-017b08103-21096.westeurope.6.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://orange-sea-0c7411a03-21096.westeurope.6.azurestaticapps.net |
The PR upgrades MSW to the latest version. The migration of interceptors has been done with the help of Claude.
Handler syntax migration (113 files)
rest→httpnamespaceres(ctx.status(), ctx.json())→HttpResponse.json()(req, res, ctx) => {}→({ request, params }) => {}Backoffice integration (
index.ts)startMockServiceWorker()before app startsTest runner (
web-test-runner.config.mjs,web-test-runner.index.ts)Other
mockServiceWorker.jsWhat to test: