Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(html): deduplicate tags when same tag appears in both describe and test title (#40374)

Dor Alagema3266a782a9e
diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.ts
index 96f71f21bd..457009782e 100644
--- a/packages/playwright/src/reporters/html.ts
+++ b/packages/playwright/src/reporters/html.ts
@@ -485,7 +485,7 @@ class HtmlBuilder {
location,
duration,
annotations: this._serializeAnnotations(test.annotations),
- tags: test.tags,
+ tags: [...new Set(test.tags)],
outcome: test.outcome(),
path,
results,
@@ -499,7 +499,7 @@ class HtmlBuilder {
location,
duration,
annotations: this._serializeAnnotations(test.annotations),
- tags: test.tags,
+ tags: [...new Set(test.tags)],
outcome: test.outcome(),
path,
ok: test.outcome() === 'expected' || test.outcome() === 'flaky',
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index 258d799ae9..fb975b2ce4 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -1680,7 +1680,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
});
test.describe('labels', () => {
- test('should show labels in the test row', async ({ runInlineTest, showReport, page }) => {
+ test('should show labels in the test row', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/40368' } }, async ({ runInlineTest, showReport, page }) => {
const result = await runInlineTest({
'playwright.config.js': `
module.exports = {
@@ -1694,8 +1694,10 @@ for (const useIntermediateMergeReport of [true, false] as const) {
`,
'a.test.js': `
const { expect, test } = require('@playwright/test');
- test('@smoke @passed passed', async ({}) => {
- expect(1).toBe(1);
+ test.describe('@smoke tests', () => {
+ test('@smoke @passed passed', async ({}) => {
+ expect(1).toBe(1);
+ });
});
`,
'b.test.js': `
@@ -1752,7 +1754,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
'regression',
'flaky',
]);
- await expect(page.locator('.test-file-test', { has: page.getByText('@smoke @passed passed', { exact: true }) }).locator('.label')).toHaveText([
+ await expect(page.locator('.test-file-test', { has: page.getByText('@smoke tests › @smoke @passed passed', { exact: true }) }).locator('.label')).toHaveText([
'chromium',
'smoke',
'passed',
@@ -2617,6 +2619,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await expect(page.locator('.header-title')).toHaveText('Test passed -- @call @call-details @e2e @regression #VQ457');
await expect(page.locator('.label')).toHaveText(['firefox', 'Monitoring', 'call', 'call-details', 'e2e', 'regression']);
});
+
});
test('should list tests in the right order', async ({ runInlineTest, showReport, page }) => {
diff --git a/tests/playwright-test/test-tag.spec.ts b/tests/playwright-test/test-tag.spec.ts
index 31cc1371b4..e3967a8b98 100644
--- a/tests/playwright-test/test-tag.spec.ts
+++ b/tests/playwright-test/test-tag.spec.ts
@@ -91,6 +91,7 @@ test('should have correct tags', async ({ runInlineTest }) => {
]);
});
+
test('config.grep should work', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `