File tree Expand file tree Collapse file tree 8 files changed +83
-50
lines changed Expand file tree Collapse file tree 8 files changed +83
-50
lines changed Original file line number Diff line number Diff line change 11import { setupWorker } from 'msw/browser'
22import { handlers } from './handlers'
33
4- window . worker = setupWorker ( ...handlers )
4+ export const worker = setupWorker ( ...handlers )
Original file line number Diff line number Diff line change 77 < script >
88 globalThis . process = { env : { } }
99 </ script >
10- < script type ="module " src ="/browser.js "> </ script >
1110 < script type ="module ">
12- await window . worker . start ( )
11+ if ( process . env . NODE_ENV === 'development' ) {
12+ const { worker } = await import ( './browser.js' )
13+ await worker . start ( )
14+ }
1315
1416 async function main ( ) {
1517 fetch ( '/user' )
Original file line number Diff line number Diff line change 1- import { test , expect } from '@playwright/test'
1+ import { expect } from '@playwright/test'
2+ import { test } from './playwright.utils.js'
23
34test ( 'receives a mocked response to a REST API request' , async ( { page } ) => {
45 await page . goto ( '/' , { waitUntil : 'networkidle' } )
Original file line number Diff line number Diff line change 66 "postinstall" : " pnpm exec playwright install"
77 },
88 "devDependencies" : {
9- "@playwright/test" : " ^1.40.1" ,
9+ "@msw/playwright" : " ^0.4.2" ,
10+ "@playwright/test" : " ^1.55.0" ,
1011 "@web/dev-server" : " ^0.2.1" ,
1112 "msw" : " 2.11.2" ,
12- "playwright" : " ^1.33 .0" ,
13+ "playwright" : " ^1.55 .0" ,
1314 "typescript" : " ^5.0.4"
1415 },
1516 "msw" : {
Original file line number Diff line number Diff line change 1+ import { test as testBase } from '@playwright/test'
2+ import { createNetworkFixture , type NetworkFixture } from '@msw/playwright'
3+ import { handlers } from './app/handlers.js'
4+
5+ interface Fixtures {
6+ network : NetworkFixture
7+ }
8+
9+ // Set up `test` with the msw playwright binding following https://github.com/mswjs/playwright
10+ export const test = testBase . extend < Fixtures > ( {
11+ // Create a fixture that will control the network in your tests.
12+ network : createNetworkFixture ( {
13+ initialHandlers : handlers ,
14+ } ) ,
15+ } )
Original file line number Diff line number Diff line change 2020 "react-dom" : " ^18.2.0"
2121 },
2222 "devDependencies" : {
23- "@playwright/test" : " ^1.33 .0" ,
23+ "@playwright/test" : " ^1.55 .0" ,
2424 "@remix-run/dev" : " ^1.15.0" ,
2525 "@remix-run/eslint-config" : " ^1.15.0" ,
2626 "@types/react" : " ^18.0.35" ,
2727 "@types/react-dom" : " ^18.0.11" ,
2828 "eslint" : " ^8.38.0" ,
2929 "msw" : " 2.11.2" ,
30- "playwright" : " ^1.33 .0" ,
30+ "playwright" : " ^1.55 .0" ,
3131 "typescript" : " ^4.9.5"
3232 },
3333 "engines" : {
Original file line number Diff line number Diff line change 1515 "postinstall" : " pnpm exec playwright install"
1616 },
1717 "devDependencies" : {
18- "@playwright/test" : " ^1.33 .0" ,
18+ "@playwright/test" : " ^1.55 .0" ,
1919 "@sveltejs/adapter-auto" : " ^2.0.1" ,
2020 "@sveltejs/kit" : " ^1.16.2" ,
2121 "@typescript-eslint/eslint-plugin" : " ^5.59.2" ,
2424 "eslint-config-prettier" : " ^8.8.0" ,
2525 "eslint-plugin-svelte" : " ^2.27.4" ,
2626 "msw" : " 2.11.2" ,
27- "playwright" : " ^1.33 .0" ,
27+ "playwright" : " ^1.55 .0" ,
2828 "prettier" : " ^2.8.8" ,
2929 "prettier-plugin-svelte" : " ^2.10.0" ,
3030 "svelte" : " ^3.59.0" ,
You can’t perform that action at this time.
0 commit comments