fix(runner): hide APIResponse.* calls from results (#34909)

This commit is contained in:
Simon Knott 2025-02-25 14:26:54 +01:00 committed by GitHub
parent 81855d11e4
commit 9e38473309
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View file

@ -338,16 +338,18 @@ export class APIResponse implements api.APIResponse {
} }
async body(): Promise<Buffer> { async body(): Promise<Buffer> {
try { return await this._request._wrapApiCall(async () => {
const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }); try {
if (result.binary === undefined) const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() });
throw new Error('Response has been disposed'); if (result.binary === undefined)
return result.binary; throw new Error('Response has been disposed');
} catch (e) { return result.binary;
if (isTargetClosedError(e)) } catch (e) {
throw new Error('Response has been disposed'); if (isTargetClosedError(e))
throw e; throw new Error('Response has been disposed');
} throw e;
}
}, true);
} }
async text(): Promise<string> { async text(): Promise<string> {

View file

@ -1520,9 +1520,7 @@ pw:api | browserContext.newPage
test.step |custom step @ a.test.ts:4 test.step |custom step @ a.test.ts:4
pw:api | page.route @ a.test.ts:5 pw:api | page.route @ a.test.ts:5
pw:api | page.goto(${server.EMPTY_PAGE}) @ a.test.ts:12 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 expect | expect.toBe @ a.test.ts:8
pw:api | apiResponse.text @ a.test.ts:9
hook |After Hooks hook |After Hooks
fixture | fixture: page fixture | fixture: page
fixture | fixture: context fixture | fixture: context