From 7aa42a6637305df993e7f0a459f85c1d9245a56c Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 25 Feb 2025 08:16:13 +0100 Subject: [PATCH] fix(runner): hide APIResponse.* calls from results --- packages/playwright/src/index.ts | 2 +- tests/playwright-test/test-step.spec.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index e8afe5a74a..8e17c5f870 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -258,7 +258,7 @@ const playwrightFixtures: Fixtures = ({ 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('stepZone'); if (zone && zone.category === 'expect') { diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts index d35e9de57a..3e8eef9994 100644 --- a/tests/playwright-test/test-step.spec.ts +++ b/tests/playwright-test/test-step.spec.ts @@ -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