From 9e384733099f5bb02a7673d7811534142f274c38 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 25 Feb 2025 14:26:54 +0100 Subject: [PATCH] fix(runner): hide `APIResponse.*` calls from results (#34909) --- packages/playwright-core/src/client/fetch.ts | 22 +++++++++++--------- tests/playwright-test/test-step.spec.ts | 2 -- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.ts index 8bdf38631d..dada11ed30 100644 --- a/packages/playwright-core/src/client/fetch.ts +++ b/packages/playwright-core/src/client/fetch.ts @@ -338,16 +338,18 @@ export class APIResponse implements api.APIResponse { } async body(): Promise { - try { - const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }); - if (result.binary === undefined) - throw new Error('Response has been disposed'); - return result.binary; - } catch (e) { - if (isTargetClosedError(e)) - throw new Error('Response has been disposed'); - throw e; - } + return await this._request._wrapApiCall(async () => { + try { + const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }); + if (result.binary === undefined) + throw new Error('Response has been disposed'); + return result.binary; + } catch (e) { + if (isTargetClosedError(e)) + throw new Error('Response has been disposed'); + throw e; + } + }, true); } async text(): Promise { diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts index d35e9de57a..1cb8950ccf 100644 --- a/tests/playwright-test/test-step.spec.ts +++ b/tests/playwright-test/test-step.spec.ts @@ -1520,9 +1520,7 @@ pw:api | browserContext.newPage test.step |custom step @ a.test.ts:4 pw:api | page.route @ a.test.ts:5 pw:api | page.goto(${server.EMPTY_PAGE}) @ a.test.ts:12 -pw:api | apiResponse.text @ a.test.ts:7 expect | expect.toBe @ a.test.ts:8 -pw:api | apiResponse.text @ a.test.ts:9 hook |After Hooks fixture | fixture: page fixture | fixture: context