diff --git a/packages/html-reporter/src/testCaseView.spec.tsx b/packages/html-reporter/src/testCaseView.spec.tsx
index dd9b3b83b1..f1f8e45306 100644
--- a/packages/html-reporter/src/testCaseView.spec.tsx
+++ b/packages/html-reporter/src/testCaseView.spec.tsx
@@ -77,6 +77,18 @@ test('should render test case', async ({ mount }) => {
await expect(component.getByText('My test')).toBeVisible();
});
+test('should correctly set the page title and favicon', async ({ mount, page }) => {
+ await mount();
+ expect(await page.locator('link[rel="icon"]').getAttribute('href')).toEqual('../logo_expected.svg');
+ expect(await page.title()).toEqual(`| ${testCase.title}`);
+});
+
+test('should fallback to default title and favicon', async ({ mount, page }) => {
+ await mount();
+ expect(await page.locator('link[rel="icon"]').getAttribute('href')).toEqual('../logo_default.svg');
+ expect(await page.title()).toEqual('Playwright Test Report');
+});
+
const linkRenderingTestCase: TestCase = {
testId: 'testid',
title: 'My test',
@@ -95,12 +107,6 @@ const linkRenderingTestCase: TestCase = {
results: [result]
};
-test('should correctly set the page title and favicon', async ({ mount, page }) => {
- await mount();
- expect(await page.locator('link[rel="icon"]').getAttribute('href')).toEqual('../logo_expected.svg');
- expect(await page.title()).toEqual(`| ${linkRenderingTestCase.title}`);
-});
-
test('should correctly render links in annotations', async ({ mount, page }) => {
const component = await mount();
// const container = await(component.getByText('Annotations'));
diff --git a/packages/html-reporter/src/testCaseView.tsx b/packages/html-reporter/src/testCaseView.tsx
index 418edb58cc..8637622155 100644
--- a/packages/html-reporter/src/testCaseView.tsx
+++ b/packages/html-reporter/src/testCaseView.tsx
@@ -45,7 +45,7 @@ export const TestCaseView: React.FC<{
}, [test?.annotations]);
React.useEffect(() => {
- document.title = `| ${test?.title}` ?? 'Playwright Test Report';
+ document.title = test?.title ? `| ${test.title}` : 'Playwright Test Report';
setSvgFavicon(test?.outcome);
}, [test?.outcome, test?.title]);