Runtime request handlers in the browser (Playwright, Remix) #2318
-
👋🏽 I'm opening the question here but feel free to redirect me to Discord/Issue in The ProblemI would like to use runtime handlers in my tests in a SvelteKit project (+ I tried with Remix and there seems to be a similar problem. I pushed a version of mswjs/examples@main...oscard0m:msw-examples:example-runtime-handlers-remix-svelte Any hint on how can I debug this or... what should be the best approach? Thank you @kettanaito ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, @oscard0m. If you are in Playwright, you are running tests in the browser. For that, you need to deal with
test('my test', async ({ page }) => {
await page.evaluate(() => {
const { worker, http } = window.msw
worker.use(http.get('/override', resolver))
})
})
|
Beta Was this translation helpful? Give feedback.
Hi, @oscard0m.
If you are in Playwright, you are running tests in the browser. For that, you need to deal with
worker
, notserver.
worker
onwindow
(or any other method of your choosing to have it available during the tests).window.worker
to add runtime handlers.