From 18ccdc53b8109192c393963a30cec5df07f69a43 Mon Sep 17 00:00:00 2001 From: Pradap Pandiyan Date: Sun, 5 Jul 2026 18:17:29 +0400 Subject: [PATCH 1/3] feat(test-runner): log aria snapshot failures during error context capture Replace empty catch in _takePageSnapshot with debugLogger.log under pw:api so best-effort snapshot failures are observable when debugging. Fixes #41536. --- packages/playwright/src/index.ts | 5 ++++- tests/playwright-test/playwright.spec.ts | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index d9be54325effd..224704570c988 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -24,6 +24,7 @@ import { escapeHTML } from '@isomorphic/stringUtils'; import { jsonStringifyForceASCII } from '@utils/ascii'; import { createGuid } from '@utils/crypto'; import { debugMode } from '@utils/debug'; +import { debugLogger } from '@utils/debugLogger'; import { currentZone } from '@utils/zones'; import { buildErrorContext } from './errorContext'; import { config, testType } from './common'; @@ -740,7 +741,9 @@ class ArtifactsRecorder { await page._wrapApiCall(async () => { this._pageSnapshot = await page.ariaSnapshot({ mode: 'ai', timeout: 5000 }); }, { internal: true }); - } catch {} + } catch (error) { + debugLogger.log('api', `ariaSnapshot: failed to capture snapshot during error (may be expected): ${error}`); + } } async didCreateRequestContext(context: APIRequestContextImpl) { diff --git a/tests/playwright-test/playwright.spec.ts b/tests/playwright-test/playwright.spec.ts index d3214690c221e..b15d5ba58a647 100644 --- a/tests/playwright-test/playwright.spec.ts +++ b/tests/playwright-test/playwright.spec.ts @@ -525,6 +525,26 @@ test('should work with video: on-first-retry', async ({ runInlineTest }) => { }, errorPrompt]); }); +test('should log aria snapshot failures with DEBUG=pw:api', async ({ runInlineTest }) => { + test.slow(); + const result = await runInlineTest({ + 'playwright.config.ts': ` + module.exports = { name: 'chromium', timeout: 30000 }; + `, + 'a.test.ts': ` + import { test, expect } from '@playwright/test'; + test('fail', async ({ page }) => { + await page.goto('about:blank'); + await page.evaluate(() => document.documentElement.remove()); + expect(1).toBe(2); + }); + `, + }, { workers: 1 }, { DEBUG: 'pw:api' }); + + expect(result.exitCode).toBe(1); + expect(result.stderr + result.output).toContain('ariaSnapshot: failed to capture snapshot during error (may be expected)'); +}); + test('should work with video: on-all-retries', async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': ` From f556016a187579f04b4a7b69417299b9f15895dc Mon Sep 17 00:00:00 2001 From: Pradap Pandiyan Date: Tue, 7 Jul 2026 17:09:50 +0400 Subject: [PATCH 2/3] test(test-runner): drop debug output test for aria snapshot logging We generally don't test debug output. --- tests/playwright-test/playwright.spec.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tests/playwright-test/playwright.spec.ts b/tests/playwright-test/playwright.spec.ts index b15d5ba58a647..d3214690c221e 100644 --- a/tests/playwright-test/playwright.spec.ts +++ b/tests/playwright-test/playwright.spec.ts @@ -525,26 +525,6 @@ test('should work with video: on-first-retry', async ({ runInlineTest }) => { }, errorPrompt]); }); -test('should log aria snapshot failures with DEBUG=pw:api', async ({ runInlineTest }) => { - test.slow(); - const result = await runInlineTest({ - 'playwright.config.ts': ` - module.exports = { name: 'chromium', timeout: 30000 }; - `, - 'a.test.ts': ` - import { test, expect } from '@playwright/test'; - test('fail', async ({ page }) => { - await page.goto('about:blank'); - await page.evaluate(() => document.documentElement.remove()); - expect(1).toBe(2); - }); - `, - }, { workers: 1 }, { DEBUG: 'pw:api' }); - - expect(result.exitCode).toBe(1); - expect(result.stderr + result.output).toContain('ariaSnapshot: failed to capture snapshot during error (may be expected)'); -}); - test('should work with video: on-all-retries', async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': ` From 101b5d2bee02e1ae3209e5b9d8a4a97e625046e0 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 7 Jul 2026 15:16:15 +0200 Subject: [PATCH 3/3] Update packages/playwright/src/index.ts Signed-off-by: Simon Knott --- packages/playwright/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 224704570c988..34f9d6dedaba3 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -742,7 +742,7 @@ class ArtifactsRecorder { this._pageSnapshot = await page.ariaSnapshot({ mode: 'ai', timeout: 5000 }); }, { internal: true }); } catch (error) { - debugLogger.log('api', `ariaSnapshot: failed to capture snapshot during error (may be expected): ${error}`); + debugLogger.log('error', `failed to capture aria snapshot: ${error}`); } }