fix(browser): allow service workers to mock the network in chromium without breaking vi.mock#8668
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
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' |
There was a problem hiding this comment.
Maybe we should do ??= to allow user-override
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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
…Georgegriff/vitest into fix-service-worker-traffic-interception
|
Thanks! |
…ithout breaking vi.mock (#8668) Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
|
@sheremet-va good news as of playwright 1.57 (microsoft/playwright#37868) this api is no longer experimental so as long as people have playwright 1.57 this flag can be deleted |
We support older versions too, so I don't think we can remove it yet. |
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:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.