@msw/playwright 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Page, PlaywrightTestArgs, PlaywrightWorkerArgs, TestFixture } from "@pl
3
3
 
4
4
  //#region src/fixture.d.ts
5
5
  interface CreateNetworkFixtureArgs {
6
- initialHandlers: Array<RequestHandler | WebSocketHandler>;
6
+ initialHandlers?: Array<RequestHandler | WebSocketHandler>;
7
7
  onUnhandledRequest?: UnhandledRequestStrategy;
8
8
  }
9
9
  /**
package/build/index.js CHANGED
@@ -56,7 +56,11 @@ var NetworkFixture = class extends SetupApi {
56
56
  const handlers = this.handlersController.currentHandlers().filter((handler) => {
57
57
  return handler instanceof RequestHandler;
58
58
  });
59
- const response = await handleRequest(fetchRequest, crypto.randomUUID(), handlers, { onUnhandledRequest: this.args.onUnhandledRequest || "warn" }, this.emitter, { resolutionContext: {
59
+ /**
60
+ * @note Use `handleRequest` instead of `getResponse` so we can pass
61
+ * the `onUnhandledRequest` option as-is and benefit from MSW's default behaviors.
62
+ */
63
+ const response = await handleRequest(fetchRequest, crypto.randomUUID(), handlers, { onUnhandledRequest: this.args.onUnhandledRequest || "bypass" }, this.emitter, { resolutionContext: {
60
64
  quiet: true,
61
65
  baseUrl: this.getPageUrl()
62
66
  } });
@@ -93,11 +97,11 @@ var NetworkFixture = class extends SetupApi {
93
97
  }
94
98
  async stop() {
95
99
  super.dispose();
96
- await this.#page.unroute(INTERNAL_MATCH_ALL_REG_EXP);
97
- await unrouteWebSocket(this.#page, INTERNAL_MATCH_ALL_REG_EXP);
100
+ await this.args.page.unroute(INTERNAL_MATCH_ALL_REG_EXP);
101
+ await unrouteWebSocket(this.args.page, INTERNAL_MATCH_ALL_REG_EXP);
98
102
  }
99
103
  getPageUrl() {
100
- const url = this.#page.url();
104
+ const url = this.args.page.url();
101
105
  return url !== "about:blank" ? url : void 0;
102
106
  }
103
107
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@msw/playwright",
4
- "version": "0.4.4",
4
+ "version": "0.4.5",
5
5
  "description": "Mock Service Worker binding for Playwright",
6
6
  "main": "./build/index.js",
7
7
  "types": "./build/index.d.ts",