Skip to content

Conversation

@Georgegriff
Copy link
Contributor

@Georgegriff Georgegriff commented Oct 6, 2025

Description

Fix for mswjs/msw#2589

Fixes #8473
Fixes #8410

Fixes the use of service workers (msw) to mock APIs in playwright

Things to note

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Oct 6, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8a4fe0b
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/68f6abb4be892c0008e42b39
😎 Deploy Preview https://deploy-preview-8668--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.


// Enable intercepting of requests made by service workers - experimental API is only available in Chromium based browsers
// Requests from service workers are only available on context.route() https://playwright.dev/docs/service-workers-experimental
process.env.PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS = '1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should do ??= to allow user-override

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, because the docs say this

Set the PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS environment variable to 1 (or any other value) to enable the feature. Only Chrome/Chromium are currently supported.

it's unclear to me if user setting '' will work but no harm in this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheremet-va what Is needed to progress this pr? I saw some of the checks failed but I'm not sure they are caused by my change, hard to tell

@sheremet-va sheremet-va merged commit 87108db into vitest-dev:main Oct 21, 2025
11 of 14 checks passed
@sheremet-va
Copy link
Member

Thanks!

@Georgegriff
Copy link
Contributor Author

@sheremet-va good news as of playwright 1.57 (