diff --git a/packages/html-reporter/src/testFilesView.tsx b/packages/html-reporter/src/testFilesView.tsx index 710beaf3ad0ca..51a3780f77664 100644 --- a/packages/html-reporter/src/testFilesView.tsx +++ b/packages/html-reporter/src/testFilesView.tsx @@ -45,12 +45,12 @@ export const TestFilesView: React.FC<{ return <>
{projectNames.length === 1 && !!projectNames[0] &&
Project: {projectNames[0]}
} - {!filter.empty() &&
Filtered: {filteredStats.total}
} + {!filter.empty() &&
Filtered: {filteredStats.total} {!!filteredStats.total && ('(' + msToString(filteredStats.duration) + ')')}
}
{report ? new Date(report.startTime).toLocaleString() : ''}
-
Total time: {msToString(filteredStats.duration)}
+
Total time: {msToString(report?.duration ?? 0)}
- {report && report.errors.length && + {report && !!report.errors.length && {report.errors.map((error, index) => )} } {report && filteredFiles.map(({ file, defaultExpanded }) => { diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.ts index 4f273be2d3c05..e44216f0632eb 100644 --- a/tests/playwright-test/reporter-blob.spec.ts +++ b/tests/playwright-test/reporter-blob.spec.ts @@ -388,7 +388,7 @@ test('total time is from test run not from merge', async ({ runInlineTest, merge // "Total time: 2.1s" const time = /Total time: (\d+)(\.\d+)?s/.exec(durationText); expect(time).toBeTruthy(); - expect(parseInt(time[1], 10)).toBeGreaterThan(2); + expect(parseInt(time[1], 10)).toBeGreaterThanOrEqual(2); }); test('merge into list report by default', async ({ runInlineTest, mergeReports }) => { diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts index 9a82a0f87da69..8090972125d0d 100644 --- a/tests/playwright-test/reporter-html.spec.ts +++ b/tests/playwright-test/reporter-html.spec.ts @@ -1356,11 +1356,7 @@ for (const useIntermediateMergeReport of [false, true] as const) { await expect(regressionLabelButton).not.toBeVisible(); - { - const testDuration = await page.getByTestId('test-duration').textContent(); - const totalDuration = await page.getByTestId('overall-duration').textContent(); - expect(totalDuration).toBe('Total time: ' + testDuration); - } + await expect(page.getByTestId('overall-duration')).toHaveText(`Total time: ${msToString(result.report.stats.duration)}`); await searchInput.clear(); @@ -1376,11 +1372,7 @@ for (const useIntermediateMergeReport of [false, true] as const) { await expect(page.locator('.chip', { hasText: 'b.test.js' })).toHaveCount(0); await expect(page.locator('.test-file-test .test-file-title')).toHaveText('Error Pages › @regression passes'); - { - const testDuration = await page.getByTestId('test-duration').textContent(); - const totalDuration = await page.getByTestId('overall-duration').textContent(); - expect(totalDuration).toBe('Total time: ' + testDuration); - } + await expect(page.getByTestId('overall-duration')).toHaveText(`Total time: ${msToString(result.report.stats.duration)}`); await searchInput.clear(); @@ -1534,21 +1526,15 @@ for (const useIntermediateMergeReport of [false, true] as const) { return total; } - async function checkTotalDuration(testNames: string[]) { - for (const testDuration of await page.getByTestId('test-duration').allTextContents()) - expect(testDuration).toMatch(/\d+m?s$/); - - const expectedTotalTimeInMs = calculateTotalTestDuration(testNames); - await expect(page.getByTestId('overall-duration')).toHaveText(`Total time: ${msToString(expectedTotalTimeInMs)}`); - } - const searchInput = page.locator('.subnav-search-input'); await expect(page.getByTestId('filtered-tests-count')).not.toBeVisible(); + await expect(page.getByTestId('overall-duration')).toHaveText(`Total time: ${msToString(result.report.stats.duration)}`); await searchInput.fill('s:failed'); - await expect(page.getByTestId('filtered-tests-count')).toHaveText('Filtered: 3'); - await checkTotalDuration(['a-one foo', 'a-two foo', 'b-one foo']); + const threeTestsDuration = calculateTotalTestDuration(['a-one foo', 'a-two foo', 'b-one foo']); + await expect(page.getByTestId('filtered-tests-count')).toHaveText(`Filtered: 3 (${msToString(threeTestsDuration)})`); + await expect(page.getByTestId('overall-duration')).toHaveText(`Total time: ${msToString(result.report.stats.duration)}`); await expect(page.locator('.subnav-item:has-text("All") .counter')).toHaveText('10'); await expect(page.locator('.subnav-item:has-text("Passed") .counter')).toHaveText('7'); await expect(page.locator('.subnav-item:has-text("Failed") .counter')).toHaveText('3'); @@ -1559,8 +1545,9 @@ for (const useIntermediateMergeReport of [false, true] as const) { await expect(page.getByTestId('filtered-tests-count')).not.toBeVisible(); await searchInput.fill('foo'); - await expect(page.getByTestId('filtered-tests-count')).toHaveText('Filtered: 4'); - await checkTotalDuration(['a-one foo', 'a-two foo', 'b-one foo', 'b-two foo']); + const fourTestsDuration = calculateTotalTestDuration(['a-one foo', 'a-two foo', 'b-one foo', 'b-two foo']); + await expect(page.getByTestId('filtered-tests-count')).toHaveText(`Filtered: 4 (${msToString(fourTestsDuration)})`); + await expect(page.getByTestId('overall-duration')).toHaveText(`Total time: ${msToString(result.report.stats.duration)}`); await expect(page.locator('.subnav-item:has-text("All") .counter')).toHaveText('10'); await expect(page.locator('.subnav-item:has-text("Passed") .counter')).toHaveText('7'); await expect(page.locator('.subnav-item:has-text("Failed") .counter')).toHaveText('3');