Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/with-jest-jsdom/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default {

// (Optional) Add suppor for TypeScript in Jest.
transform: {
'^.+\\.tsx?$': '@swc/jest',
'^.+\\.(js|ts)x?$': '@swc/jest',
},
// Transform ESM-only until-async package.
transformIgnorePatterns: [
'../../node_modules/.pnpm/(?!(until-async)@)',
],
} satisfies Config
4 changes: 2 additions & 2 deletions examples/with-jest-jsdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"@types/node": "^18",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-fixed-jsdom": "^0.0.9",
"msw": "2.11.2",
"jest-fixed-jsdom": "^0.0.11",
"msw": "2.12.10",
"ts-node": "^10.9.2",
"typescript": "^5.0.4"
}
Expand Down
6 changes: 5 additions & 1 deletion examples/with-jest/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export default {
rootDir: __dirname,
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
transform: {
'^.+\\.tsx?$': '@swc/jest',
'^.+\\.(js|ts)x?$': '@swc/jest',
},
// Transform ESM-only until-async package.
transformIgnorePatterns: [
'../../node_modules/.pnpm/(?!(until-async)@)',
],
} satisfies Config
2 changes: 1 addition & 1 deletion examples/with-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@types/jest": "^29.5.1",
"@types/node": "^18",
"jest": "^29.5.0",
"msw": "2.11.2",
"msw": "2.12.10",
"ts-node": "^10.9.2",
"typescript": "^5.0.4",
"with-angular": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions examples/with-karma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"karma-mocha-reporter": "^2.2.5",
"karma-webpack": "^5.0.0",
"mocha": "^10.2.0",
"msw": "2.11.2",
"msw": "2.12.10",
"webpack": "^5.81.0"
},
"msw": {
"workerDirectory": "test"
}
}
}
3 changes: 2 additions & 1 deletion examples/with-karma/test/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Please do NOT modify this file.
*/

const PACKAGE_VERSION = '2.11.2'
const PACKAGE_VERSION = '2.12.10'
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down Expand Up @@ -205,6 +205,7 @@ async function resolveMainClient(event) {
* @param {FetchEvent} event
* @param {Client | undefined} client
* @param {string} requestId
* @param {number} requestInterceptedAt
* @returns {Promise<Response>}
*/
async function getResponse(event, client, requestId, requestInterceptedAt) {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-playwright/app/browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setupWorker } from 'msw/browser'
import { handlers } from './handlers'

window.worker = setupWorker(...handlers)
export const worker = setupWorker(...handlers)
6 changes: 4 additions & 2 deletions examples/with-playwright/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<script>
globalThis.process = { env: {} }
</script>
<script type="module" src="/browser.js"></script>
<script type="module">
await window.worker.start()
if (process.env.NODE_ENV === 'development') {
const { worker } = await import('./browser.js')
await worker.start()
}

async function main() {
fetch('/user')
Expand Down
3 changes: 2 additions & 1 deletion examples/with-playwright/app/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Please do NOT modify this file.
*/

const PACKAGE_VERSION = '2.11.2'
const PACKAGE_VERSION = '2.12.10'
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down Expand Up @@ -205,6 +205,7 @@ async function resolveMainClient(event) {
* @param {FetchEvent} event
* @param {Client | undefined} client
* @param {string} requestId
* @param {number} requestInterceptedAt
* @returns {Promise<Response>}
*/
async function getResponse(event, client, requestId, requestInterceptedAt) {
Expand Down
3 changes: 2 additions & 1 deletion examples/with-playwright/example.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import { expect } from '@playwright/test'
import { test } from './playwright.setup.js'

test('receives a mocked response to a REST API request', async ({ page }) => {
await page.goto('/', { waitUntil: 'networkidle' })
Expand Down
8 changes: 5 additions & 3 deletions examples/with-playwright/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"name": "with-playwright",
"type": "module",
"scripts": {
"dev": "web-dev-server --root-dir ./app --node-resolve --watch",
"test": "playwright test",
"postinstall": "pnpm exec playwright install"
},
"devDependencies": {
"@playwright/test": "^1.40.1",
"@msw/playwright": "^0.6.5",
"@playwright/test": "^1.58.2",
"@web/dev-server": "^0.2.1",
"msw": "2.11.2",
"playwright": "^1.33.0",
"msw": "2.12.10",
"playwright": "^1.58.2",
"typescript": "^5.0.4"
},
"msw": {
Expand Down
29 changes: 29 additions & 0 deletions examples/with-playwright/playwright.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { test as testBase } from '@playwright/test'
import { type AnyHandler } from 'msw'
import { defineNetworkFixture, type NetworkFixture } from '@msw/playwright'
import { handlers } from './app/handlers.js'

interface Fixtures {
handlers: Array<AnyHandler>
network: NetworkFixture
}

export const test = testBase.extend<Fixtures>({
// Initial list of the network handlers.
handlers: [handlers, { option: true }],

// A fixture you use to control the network in your tests.
network: [
async ({ context, handlers }, use) => {
const network = defineNetworkFixture({
context,
handlers,
})

await network.enable()
await use(network)
await network.disable()
},
{ auto: true },
],
})
4 changes: 2 additions & 2 deletions examples/with-remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@playwright/test": "^1.33.0",
"@playwright/test": "^1.55.0",
"@remix-run/dev": "^1.15.0",
"@remix-run/eslint-config": "^1.15.0",
"@types/react": "^18.0.35",
"@types/react-dom": "^18.0.11",
"eslint": "^8.38.0",
"msw": "2.11.2",
"playwright": "^1.33.0",
"playwright": "^1.55.0",
"typescript": "^4.9.5"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions examples/with-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"postinstall": "pnpm exec playwright install"
},
"devDependencies": {
"@playwright/test": "^1.33.0",
"@playwright/test": "^1.58.2",
"@sveltejs/adapter-auto": "^2.0.1",
"@sveltejs/kit": "^1.16.2",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte": "^2.27.4",
"msw": "2.11.2",
"playwright": "^1.33.0",
"msw": "2.12.10",
"playwright": "^1.58.2",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.0",
"svelte": "^3.59.0",
Expand Down
3 changes: 2 additions & 1 deletion examples/with-svelte/static/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Please do NOT modify this file.
*/

const PACKAGE_VERSION = '2.11.2'
const PACKAGE_VERSION = '2.12.10'
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down Expand Up @@ -205,6 +205,7 @@ async function resolveMainClient(event) {
* @param {FetchEvent} event
* @param {Client | undefined} client
* @param {string} requestId
* @param {number} requestInterceptedAt
* @returns {Promise<Response>}
*/
async function getResponse(event, client, requestId, requestInterceptedAt) {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vitest-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"devDependencies": {
"jsdom": "^21.1.1",
"msw": "2.11.2",
"msw": "2.12.10",
"typescript": "^5.0.4",
"vitest": "^0.30.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"devDependencies": {
"jsdom": "^21.1.1",
"msw": "2.11.2",
"msw": "2.12.10",
"typescript": "^5.0.4",
"vitest": "^0.30.1"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/with-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite",
"build": "run-p type-check build-only",
"test": "pnpm test:integration && pnpm test:e2e",
"test:integration": "vitest",
"test:integration": "vitest run",
"test:e2e": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress run --e2e'",
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
"build-only": "vite build",
Expand All @@ -23,7 +23,7 @@
"@vue/tsconfig": "^0.1.3",
"cypress": "^12.7.0",
"jsdom": "^21.1.0",
"msw": "2.11.2",
"msw": "2.12.10",
"npm-run-all": "^4.1.5",
"start-server-and-test": "^2.0.0",
"typescript": "~4.8.4",
Expand Down
3 changes: 2 additions & 1 deletion examples/with-vue/public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Please do NOT modify this file.
*/

const PACKAGE_VERSION = '2.11.2'
const PACKAGE_VERSION = '2.12.10'
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down Expand Up @@ -205,6 +205,7 @@ async function resolveMainClient(event) {
* @param {FetchEvent} event
* @param {Client | undefined} client
* @param {string} requestId
* @param {number} requestInterceptedAt
* @returns {Promise<Response>}
*/
async function getResponse(event, client, requestId, requestInterceptedAt) {
Expand Down
Loading