Skip to content

Commit

Permalink
chore: dedupe tags in base reporter title (#33461)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Nov 6, 2024
1 parent a655b0b commit 9d94ad1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/playwright/src/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,9 @@ export function formatTestTitle(config: FullConfig, test: TestCase, step?: TestS
else
location = `${relativeTestPath(config, test)}:${step?.location?.line ?? test.location.line}:${step?.location?.column ?? test.location.column}`;
const projectTitle = projectName ? `[${projectName}] › ` : '';
const tags = test.tags.length > 0 ? ` ${test.tags.join(' ')}` : '';
return `${projectTitle}${location}${titles.join(' › ')}${stepSuffix(step)}${tags}`;
const testTitle = `${projectTitle}${location}${titles.join(' › ')}`;
const extraTags = test.tags.filter(t => !testTitle.includes(t));
return `${testTitle}${stepSuffix(step)}${extraTags.length ? ' ' + extraTags.join(' ') : ''}`;
}

export function formatTestHeader(config: FullConfig, test: TestCase, options: { indent?: string, index?: number, mode?: 'default' | 'error' } = {}): string {
Expand Down
17 changes: 12 additions & 5 deletions tests/playwright-test/reporter-base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { test, expect } from './playwright-test-fixtures';
import { test, expect, stripAnsi } from './playwright-test-fixtures';
import * as path from 'path';

for (const useIntermediateMergeReport of [false, true] as const) {
Expand Down Expand Up @@ -470,14 +470,21 @@ for (const useIntermediateMergeReport of [false, true] as const) {
const result = await runInlineTest({
'a.test.ts': `
const { test, expect } = require('@playwright/test');
test('passes', { tag: ['@foo', '@bar'] }, async ({}) => {
test('passes', { tag: ['@foo1', '@foo2'] }, async ({}) => {
expect(0).toBe(0);
});
test('passes @bar1 @bar2', async ({}) => {
expect(0).toBe(0);
});
test('passes @baz1', { tag: ['@baz2'] }, async ({}) => {
expect(0).toBe(0);
});
`,
});
const text = result.output;

expect(text).toContain('passes @foo @bar');
const text = stripAnsi(result.output);
expect(text).toContain('› passes @foo1 @foo2 (');
expect(text).toContain('› passes @bar1 @bar2 (');
expect(text).toContain('› passes @baz1 @baz2 (');
});
});
}

0 comments on commit 9d94ad1

Please sign in to comment.