Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add 'should show errors with causes in the error tab' #33577

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/playwright-test/ui-mode-trace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': `
Expand Down