From 36855598bedad06cbd9d3cbb68b0e1b10c1ae372 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Mon, 3 Feb 2025 14:43:17 +0100 Subject: [PATCH] update assertion --- packages/playwright-core/src/client/network.ts | 2 ++ tests/playwright-test/playwright.mockingproxy.spec.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.ts index beff573146..cac330e879 100644 --- a/packages/playwright-core/src/client/network.ts +++ b/packages/playwright-core/src/client/network.ts @@ -201,6 +201,8 @@ export class Request extends ChannelOwner implements ap } frame(): Frame { + if (this._pageForMockingProxy) + throw new Error('Frame for this request is not available, because the request was issued on the server.'); if (!this._initializer.frame) { assert(this.serviceWorker()); throw new Error('Service Worker requests do not have an associated frame.'); diff --git a/tests/playwright-test/playwright.mockingproxy.spec.ts b/tests/playwright-test/playwright.mockingproxy.spec.ts index b5293ef26a..51a3636402 100644 --- a/tests/playwright-test/playwright.mockingproxy.spec.ts +++ b/tests/playwright-test/playwright.mockingproxy.spec.ts @@ -110,7 +110,7 @@ test('all properties are populated', async ({ runInlineTest, server, request }) expect(await response.finished()).toBe(null); expect(request.serviceWorker()).toBe(null); - expect(() => request.frame()).toThrowError("Assertion error"); // we know the page, but not the frame. should probably improve the error message + expect(() => request.frame()).toThrowError("Frame for this request is not available, because the request was issued on the server."); expect(request.failure()).toBe(null); expect(request.isNavigationRequest()).toBe(false);