Skip to content

Conversation

@madsrasmussen
Copy link
Contributor

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)

  • resthttp namespace
  • res(ctx.status(), ctx.json())HttpResponse.json()
  • Handler signatures: (req, res, ctx) => {}({ request, params }) => {}

Backoffice integration (index.ts)

  • Wrapped bootstrap in an async function to await startMockServiceWorker() before app starts

Test runner (web-test-runner.config.mjs, web-test-runner.index.ts)

  • Changed to sequential module loading with dynamic imports
  • Ensures MSW service worker is ready before the tests execute

Other

  • Regenerated mockServiceWorker.js

What to test:

  • Please make sure that the mocked backoffice still works
  • Please make sure that the storybook build stil works

@madsrasmussen madsrasmussen marked this pull request as ready for review December 9, 2025 09:15
Copilot AI review requested due to automatic review settings December 9, 2025 09:15
@madsrasmussen madsrasmussen added release/no-notes Not directly part of the release (updating README, build scripts, tests, etc.) preview/backoffice Pull requests that can be previewed in a static version of the Backoffice preview/storybook Pull requests that can be previewed through Storybook labels Dec 9, 2025
Copy link
Contributor

Copilot AI left a 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

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://victorious-ground-017b08103-21096.westeurope.6.azurestaticapps.net

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://orange-sea-0c7411a03-21096.westeurope.6.azurestaticapps.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview/backoffice Pull requests that can be previewed in a static version of the Backoffice preview/storybook Pull requests that can be previewed through Storybook release/no-notes Not directly part of the release (updating README, build scripts, tests, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants