diff --git a/msw-2.2.1-rc.remote-server.tgz b/msw-2.2.1-rc.remote-server.tgz deleted file mode 100644 index 33ffb3f..0000000 Binary files a/msw-2.2.1-rc.remote-server.tgz and /dev/null differ diff --git a/msw-2.4.2-rc.ws-sync-handlers.tgz b/msw-2.4.2-rc.ws-sync-handlers.tgz new file mode 100644 index 0000000..ad9a595 Binary files /dev/null and b/msw-2.4.2-rc.ws-sync-handlers.tgz differ diff --git a/package.json b/package.json index 0b6ddf7..fa6ab6e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "devDependencies": { "@playwright/test": "^1.45.3", "@types/node": "^20.14.12", - "msw": "./msw-2.2.1-rc.remote-server.tgz" + "msw": "./msw-2.4.2-rc.ws-sync-handlers.tgz" }, "scripts": { "start": "node server-app/index.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac9ea0f..39b7d2d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,8 +25,8 @@ importers: specifier: ^20.14.12 version: 20.14.12 msw: - specifier: ./msw-2.2.1-rc.remote-server.tgz - version: file:msw-2.2.1-rc.remote-server.tgz + specifier: ./msw-2.4.2-rc.ws-sync-handlers.tgz + version: file:msw-2.4.2-rc.ws-sync-handlers.tgz(graphql@16.9.0) packages: @@ -36,6 +36,9 @@ packages: '@bundled-es-modules/statuses@1.0.1': resolution: {integrity: sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==} + '@bundled-es-modules/tough-cookie@0.1.6': + resolution: {integrity: sha512-dvMHbL464C0zI+Yqxbz6kZ5TOEp7GLW+pry/RWndAR8MJQAXZ2rPmIs8tziTZjeIyhSNZgZbCePtfSbdWqStJw==} + '@inquirer/confirm@3.1.17': resolution: {integrity: sha512-qCpt/AABzPynz8tr69VDvhcjwmzAryipWXtW8Vi6m651da4H/d0Bdn55LkxXD7Rp2gfgxvxzTdb66AhIA8gzBA==} engines: {node: '>=18'} @@ -52,12 +55,8 @@ packages: resolution: {integrity: sha512-m3YgGQlKNS0BM+8AFiJkCsTqHEFCWn6s/Rqye3mYwvqY6LdfUv12eSwbsgNzrYyrLXiy7IrrjDLPysaSBwEfhw==} engines: {node: '>=18'} - '@mswjs/cookies@1.1.1': - resolution: {integrity: sha512-W68qOHEjx1iD+4VjQudlx26CPIoxmIAtK4ZCexU0/UJBG6jYhcuyzKJx+Iw8uhBIGd9eba64XgWVgo20it1qwA==} - engines: {node: '>=18'} - - '@mswjs/interceptors@0.25.16': - resolution: {integrity: sha512-8QC8JyKztvoGAdPgyZy49c9vSHHAZjHagwl4RY9E8carULk8ym3iTaiawrT1YoLF/qb449h48f71XDPgkUSOUg==} + '@mswjs/interceptors@0.29.1': + resolution: {integrity: sha512-3rDakgJZ77+RiQUuSK69t1F0m8BQKA8Vh5DCS5V0DWvNY67zob2JhhQrhCO0AKLGINTRSFd1tBaHcJTkhefoSw==} engines: {node: '>=18'} '@open-draft/deferred-promise@2.2.0': @@ -95,6 +94,9 @@ packages: '@types/statuses@2.0.5': resolution: {integrity: sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==} + '@types/tough-cookie@4.0.5': + resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==} + '@types/wrap-ansi@3.0.0': resolution: {integrity: sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==} @@ -368,14 +370,17 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - msw@file:msw-2.2.1-rc.remote-server.tgz: - resolution: {integrity: sha512-/njIm8HhAiOpcDUkRFbT3IR8rRIKK2uKAxGrUvTJrDw1j8oI32UIYQburiSWJ5gBHO+wObWqkhnjh6KXkS/jUg==, tarball: file:msw-2.2.1-rc.remote-server.tgz} - version: 2.2.1-rc.remote-server + msw@file:msw-2.4.2-rc.ws-sync-handlers.tgz: + resolution: {integrity: sha512-jjcQWyrZcCfejA9Z4dl/V+3k/osEu1uFxMsriPkQDAG4bO/Q17GNiTv1vaabD0rRUqXYspe3xewwnNPZy1Y3Vw==, tarball: file:msw-2.4.2-rc.ws-sync-handlers.tgz} + version: 2.4.2-rc.ws-sync-handlers engines: {node: '>=18'} hasBin: true peerDependencies: - typescript: '>= 4.7.x <= 5.3.x' + graphql: '>= 16.8.x' + typescript: '>= 4.8.x' peerDependenciesMeta: + graphql: + optional: true typescript: optional: true @@ -435,10 +440,20 @@ packages: resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} engines: {node: '>= 0.10'} + psl@1.9.0: + resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} + + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + qs@6.11.0: resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==} engines: {node: '>=0.6'} + querystringify@2.2.0: + resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} + range-parser@1.2.1: resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} engines: {node: '>= 0.6'} @@ -451,6 +466,9 @@ packages: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} + requires-port@1.0.0: + resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} + safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} @@ -518,6 +536,10 @@ packages: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} + tough-cookie@4.1.4: + resolution: {integrity: sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==} + engines: {node: '>=6'} + tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} @@ -536,10 +558,17 @@ packages: undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + universalify@0.2.0: + resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==} + engines: {node: '>= 4.0.0'} + unpipe@1.0.0: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} + url-parse@1.5.10: + resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==} + utils-merge@1.0.1: resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} engines: {node: '>= 0.4.0'} @@ -604,6 +633,11 @@ snapshots: dependencies: statuses: 2.0.1 + '@bundled-es-modules/tough-cookie@0.1.6': + dependencies: + '@types/tough-cookie': 4.0.5 + tough-cookie: 4.1.4 + '@inquirer/confirm@3.1.17': dependencies: '@inquirer/core': 9.0.5 @@ -631,9 +665,7 @@ snapshots: dependencies: mute-stream: 1.0.0 - '@mswjs/cookies@1.1.1': {} - - '@mswjs/interceptors@0.25.16': + '@mswjs/interceptors@0.29.1': dependencies: '@open-draft/deferred-promise': 2.2.0 '@open-draft/logger': 0.3.0 @@ -675,6 +707,8 @@ snapshots: '@types/statuses@2.0.5': {} + '@types/tough-cookie@4.0.5': {} + '@types/wrap-ansi@3.0.0': {} accepts@1.3.8: @@ -901,7 +935,8 @@ snapshots: dependencies: get-intrinsic: 1.2.4 - graphql@16.9.0: {} + graphql@16.9.0: + optional: true has-flag@4.0.0: {} @@ -959,19 +994,18 @@ snapshots: ms@2.1.3: {} - msw@file:msw-2.2.1-rc.remote-server.tgz: + msw@file:msw-2.4.2-rc.ws-sync-handlers.tgz(graphql@16.9.0): dependencies: '@bundled-es-modules/cookie': 2.0.0 '@bundled-es-modules/statuses': 1.0.1 + '@bundled-es-modules/tough-cookie': 0.1.6 '@inquirer/confirm': 3.1.17 - '@mswjs/cookies': 1.1.1 - '@mswjs/interceptors': 0.25.16 + '@mswjs/interceptors': 0.29.1 '@open-draft/deferred-promise': 2.2.0 '@open-draft/until': 2.1.0 '@types/cookie': 0.6.0 '@types/statuses': 2.0.5 chalk: 4.1.2 - graphql: 16.9.0 headers-polyfill: 4.0.3 is-node-process: 1.2.0 outvariant: 1.4.3 @@ -981,6 +1015,8 @@ snapshots: strict-event-emitter: 0.5.1 type-fest: 4.23.0 yargs: 17.7.2 + optionalDependencies: + graphql: 16.9.0 transitivePeerDependencies: - bufferutil - supports-color @@ -1023,10 +1059,16 @@ snapshots: forwarded: 0.2.0 ipaddr.js: 1.9.1 + psl@1.9.0: {} + + punycode@2.3.1: {} + qs@6.11.0: dependencies: side-channel: 1.0.6 + querystringify@2.2.0: {} + range-parser@1.2.1: {} raw-body@2.5.2: @@ -1038,6 +1080,8 @@ snapshots: require-directory@2.1.1: {} + requires-port@1.0.0: {} + safe-buffer@5.2.1: {} safer-buffer@2.1.2: {} @@ -1150,6 +1194,13 @@ snapshots: toidentifier@1.0.1: {} + tough-cookie@4.1.4: + dependencies: + psl: 1.9.0 + punycode: 2.3.1 + universalify: 0.2.0 + url-parse: 1.5.10 + tr46@0.0.3: {} type-fest@0.21.3: {} @@ -1163,8 +1214,15 @@ snapshots: undici-types@5.26.5: {} + universalify@0.2.0: {} + unpipe@1.0.0: {} + url-parse@1.5.10: + dependencies: + querystringify: 2.2.0 + requires-port: 1.0.0 + utils-merge@1.0.1: {} vary@1.1.2: {} diff --git a/tests/example.spec.ts b/tests/example.spec.ts index 34b2e31..ff9fcb4 100644 --- a/tests/example.spec.ts +++ b/tests/example.spec.ts @@ -4,11 +4,11 @@ import { http, HttpResponse } from 'msw'; import { RecipePage } from './pages/Recipe.page'; test.describe('Recipes', () => { - const server = setupMockServer(); + const remote = setupMockServer(); test('List of recipes should be displayed', async ({ page }) => { // Given: RecipesApi API returns list of recipes - server.use( + remote.use( http.get('https://dummyjson.com/recipes', () => HttpResponse.json({ recipes: [{ name: 'Spaghetti Carbonara', @@ -29,7 +29,7 @@ test.describe('Recipes', () => { test.skip('Error alert should be displayed when failed to load recipes', async ({ page }) => { // Given: RecipesApi returns an error - server.use( + remote.use( http.get('https://dummyjson.com/recipes', () => HttpResponse.error()) ); diff --git a/tests/server-mocked.js b/tests/server-mocked.js index 017f2fc..b88b69b 100644 --- a/tests/server-mocked.js +++ b/tests/server-mocked.js @@ -31,7 +31,7 @@ const server = setupServer( ); server.listen({ - remotePort: 3001 + remote: true }); /** diff --git a/tests/setup.ts b/tests/setup.ts index e747d35..a430de5 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -1,20 +1,20 @@ import { test } from '@playwright/test'; import { setupRemoteServer, SetupRemoteServerApi } from 'msw/node'; -const server = setupRemoteServer(); +const remote = setupRemoteServer(); export const setupMockServer = (): SetupRemoteServerApi => { test.beforeAll(async () => { - await server.listen({ port: 3001 }); + await remote.listen(); }); - + test.afterEach(async () => { - await server.resetHandlers(); + await remote.resetHandlers(); }) - + test.afterAll(async () => { - await server.close(); + await remote.close(); }); - return server; + return remote; } \ No newline at end of file