Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: highlight "view trace" on failing tests (#35342)
Simon Knottfebb95a638c9
diff --git a/packages/html-reporter/src/testFileView.css b/packages/html-reporter/src/testFileView.cssindex 37bf428490..69ef306b70 100644--- a/packages/html-reporter/src/testFileView.css+++ b/packages/html-reporter/src/testFileView.css@@ -63,6 +63,10 @@fill: var(--color-fg-muted);}+.test-file-badge.button {+ background-color: transparent;+}+.test-file-test-outcome-skipped {color: var(--color-fg-muted);}diff --git a/packages/html-reporter/src/testFileView.tsx b/packages/html-reporter/src/testFileView.tsxindex 00ea004136..6f891533c8 100644--- a/packages/html-reporter/src/testFileView.tsx+++ b/packages/html-reporter/src/testFileView.tsx@@ -87,7 +87,18 @@ function videoBadge(test: TestCaseSummary): JSX.Element | undefined {function traceBadge(test: TestCaseSummary): JSX.Element | undefined {const firstTraces = test.results.map(result => result.attachments.filter(attachment => attachment.name === 'trace')).filter(traces => traces.length > 0)[0];- return firstTraces ? <Link href={generateTraceUrl(firstTraces)} title='View trace' className='test-file-badge'>{trace()}</Link> : undefined;+ if (!firstTraces)+ return undefined;++ const isFailed = test.outcome === 'unexpected' || test.outcome === 'flaky';++ return <Link+ href={generateTraceUrl(firstTraces)}+ title={isFailed ? 'View Failing Trace' : 'View Trace'}+ className={clsx('test-file-badge', isFailed && 'button')}>+ {trace()}+ {isFailed && <span style={{ color: 'var(--color-scale-gray-7)' }}>View Failing Trace</span>}+ </Link>;}const LabelsClickView: React.FC<React.PropsWithChildren<{diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.tsindex a8846e69ae..f72eb1486e 100644--- a/tests/playwright-test/reporter-blob.spec.ts+++ b/tests/playwright-test/reporter-blob.spec.ts@@ -706,7 +706,7 @@ test('generate html with attachment urls', async ({ runInlineTest, mergeReports,await page.goBack();// Check that trace loads.- await page.locator('div').filter({ hasText: /^a\.test\.js:13$/ }).getByRole('link', { name: 'View trace' }).click();+ await page.getByRole('link', { name: 'View Failing Trace' }).click();await expect(page).toHaveTitle('Playwright Trace Viewer');await expect(page.getByTestId('actions-tree').locator('div').filter({ hasText: /^expect\.toBe$/ })).toBeVisible();});diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.tsindex b4e1c5fa5e..a6e10b53a4 100644--- a/tests/playwright-test/reporter-html.spec.ts+++ b/tests/playwright-test/reporter-html.spec.ts@@ -619,7 +619,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {expect(result.passed).toBe(1);await showReport();- await page.getByRole('link', { name: 'View trace' }).click();+ await page.getByRole('link', { name: 'View Trace' }).click();// Trace viewer should not hang here when displaying parallal requests.await expect(page.getByTestId('actions-tree')).toContainText('apiRequestContext.get');@@ -645,14 +645,14 @@ for (const useIntermediateMergeReport of [true, false] as const) {await test.step('view via server', async () => {await showReport();- await page.locator('[title="View trace"]').click();+ await page.getByRole('link', { name: 'View Trace' }).click();await expect(page.locator('dialog')).toBeHidden();});await test.step('view via local file://', async () => {const reportFolder = testInfo.outputPath('playwright-report');await page.goto(url.pathToFileURL(path.join(reportFolder, 'index.html')).toString());- await page.locator('[title="View trace"]').click();+ await page.getByRole('link', { name: 'View Trace' }).click();await expect(page.locator('dialog')).toBeVisible();await expect(page.locator('dialog')).toContainText('must be loaded over');});