use wrapApiCall

This commit is contained in:
Simon Knott 2025-02-25 13:33:03 +01:00
parent 8ab12c0779
commit b864458988
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 13 additions and 11 deletions

View file

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

View file

@ -258,7 +258,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
onApiCallBegin: (data: ApiCallData) => { onApiCallBegin: (data: ApiCallData) => {
const testInfo = currentTestInfo(); const testInfo = currentTestInfo();
// Some special calls do not get into steps. // Some special calls do not get into steps.
if (!testInfo || data.apiName.includes('setTestIdAttribute') || data.apiName === 'tracing.groupEnd' || data.apiName.startsWith('apiResponse.')) if (!testInfo || data.apiName.includes('setTestIdAttribute') || data.apiName === 'tracing.groupEnd')
return; return;
const zone = currentZone().data<TestStepInternal>('stepZone'); const zone = currentZone().data<TestStepInternal>('stepZone');
if (zone && zone.category === 'expect') { if (zone && zone.category === 'expect') {