From eab6447ad9ded128108b9c0e88954c824c31337d Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 13 Nov 2024 17:32:32 +0100 Subject: [PATCH] test: add 'should show errors with causes in the error tab' (#33577) --- tests/playwright-test/ui-mode-trace.spec.ts | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.ts index def44e9aeb451..eb562048135b1 100644 --- a/tests/playwright-test/ui-mode-trace.spec.ts +++ b/tests/playwright-test/ui-mode-trace.spec.ts @@ -261,6 +261,38 @@ test('should not show caught errors in the errors tab', async ({ runUITest }, te await expect(page.locator('.tab-errors')).toHaveText('No errors'); }); +test('should show errors with causes in the error tab', async ({ runUITest }) => { + const { page } = await runUITest({ + 'a.spec.ts': ` + import { test, expect } from '@playwright/test'; + test('pass', async ({ page }) => { + try { + try { + const error = new Error('my-message'); + error.name = 'SpecialError'; + throw error; + } catch (e) { + try { + throw new Error('inner-message', { cause: e }); + } catch (e) { + throw new Error('outer-message', { cause: e }); + } + } + } catch (e) { + throw new Error('wrapper-message', { cause: e }); + } + }); + `, + }); + + await page.getByText('pass').dblclick(); + await page.getByText('Errors', { exact: true }).click(); + await expect(page.locator('.tab-errors')).toContainText(`Error: wrapper-message +[cause]: Error: outer-message +[cause]: Error: inner-message +[cause]: SpecialError: my-message`); +}); + test('should reveal errors in the sourcetab', async ({ runUITest }) => { const { page } = await runUITest({ 'a.spec.ts': `