Skip to content
Discussion options

You must be logged in to vote

Hey, @d-ivashchuk.

I think Playwright does not have the msw in its window context so this makes the things harder than I expected.

I think that's the main culprit. You need to set window.msw in your browser context. For example, when opening an app with Playwright, you'd have to go through the Browser integration of MSW in your app:

// src/index.js
// Also a pseudo-code, please refer to the docs!
worker.start()

window.worker = worker // <- this

When Playwright opens your app, it will have window.msw because your application sets it.

Given that everything you send to Playwright from the test undergoes serialization, the best option is to set window.msw in your application directly (you …

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
4 replies
@kettanaito
Comment options

@d-ivashchuk
Comment options

@ScubaDaniel
Comment options

@valendres
Comment options

Answer selected by d-ivashchuk
Comment options

You must be logged in to vote
4 replies
@chrisb2244
Comment options

@chrisb2244
Comment options

@valendres
Comment options

@chrisb2244
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants