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

This commit is contained in:
Simon Knott 2025-02-25 08:16:13 +01:00
parent 9b633ddd2f
commit 7aa42a6637
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 12 additions and 3 deletions

View file

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

View file

@ -1448,7 +1448,10 @@ fixture | fixture: context
});
test('reading network request / response should not be listed as step', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33558' }
annotation: [
{ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33558' },
{ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/34840' },
]
}, async ({ runInlineTest, server }) => {
const result = await runInlineTest({
'reporter.ts': stepIndentReporter,
@ -1462,6 +1465,11 @@ test('reading network request / response should not be listed as step', {
page.on('response', async response => {
await response.text();
});
await page.route('**/*', async route => {
const response = await route.fetch();
await response.text();
await route.fallback();
});
await page.goto('${server.EMPTY_PAGE}');
});
`
@ -1476,7 +1484,8 @@ fixture | fixture: context
pw:api | browser.newContext
fixture | fixture: page
pw:api | browserContext.newPage
pw:api |page.goto(${server.EMPTY_PAGE}) @ a.test.ts:10
pw:api |page.route @ a.test.ts:10
pw:api |page.goto(${server.EMPTY_PAGE}) @ a.test.ts:15
hook |After Hooks
fixture | fixture: page
fixture | fixture: context