diff --git a/docs/src/test-reporters-js.md b/docs/src/test-reporters-js.md index aaf80d97af..952d74b923 100644 --- a/docs/src/test-reporters-js.md +++ b/docs/src/test-reporters-js.md @@ -102,7 +102,6 @@ List report supports the following configuration options and environment variabl | Environment Variable Name | Reporter Config Option| Description | Default |---|---|---|---| | `PLAYWRIGHT_LIST_PRINT_STEPS` | `printSteps` | Whether to print each step on its own line. | `false` -| `PLAYWRIGHT_LIST_APPEND_TAGS` | `appendTags` | Whether to append tags to the end of the test name. | `false` | `PLAYWRIGHT_FORCE_TTY` | | Whether to produce output suitable for a live terminal. If a number is specified, it will also be used as the terminal width. | `true` when terminal is in TTY mode, `false` otherwise. | `FORCE_COLOR` | | Whether to produce colored output. | `true` when terminal is in TTY mode, `false` otherwise. diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index 433228d7e6..4249429a36 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -401,7 +401,7 @@ export function stepSuffix(step: TestStep | undefined) { return stepTitles.map(t => t.split('\n')[0]).map(t => ' › ' + t).join(''); } -export function formatTestTitle(config: FullConfig, test: TestCase, step?: TestStep, omitLocation: boolean = false, appendTags: boolean = false): string { +export function formatTestTitle(config: FullConfig, test: TestCase, step?: TestStep, omitLocation: boolean = false): string { // root, project, file, ...describes, test const [, projectName, , ...titles] = test.titlePath(); let location; @@ -410,7 +410,7 @@ 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 = appendTags && test.tags.length > 0 ? ` [${test.tags.join(', ')}]` : ''; + const tags = test.tags.length > 0 ? ` ${test.tags.join(' ')}` : ''; return `${projectTitle}${location} › ${titles.join(' › ')}${stepSuffix(step)}${tags}`; } diff --git a/packages/playwright/src/reporters/list.ts b/packages/playwright/src/reporters/list.ts index fe1518e585..2897f77aa2 100644 --- a/packages/playwright/src/reporters/list.ts +++ b/packages/playwright/src/reporters/list.ts @@ -33,12 +33,10 @@ class ListReporter extends BaseReporter { private _stepIndex = new Map(); private _needNewLine = false; private _printSteps: boolean; - private _appendTags: boolean; - constructor(options: { printSteps?: boolean; appendTags?: boolean } = {}) { + constructor(options: { printSteps?: boolean;} = {}) { super(); this._printSteps = getAsBooleanFromENV('PLAYWRIGHT_LIST_PRINT_STEPS', options.printSteps); - this._appendTags = getAsBooleanFromENV('PLAYWRIGHT_LIST_APPEND_TAGS', options.appendTags); } override onBegin(suite: Suite) { @@ -59,7 +57,7 @@ class ListReporter extends BaseReporter { this._maybeWriteNewLine(); this._testRows.set(test, this._lastRow); const prefix = this._testPrefix(index, ''); - const line = colors.dim(formatTestTitle(this.config, test, undefined, false, this._appendTags)) + this._retrySuffix(result); + const line = colors.dim(formatTestTitle(this.config, test)) + this._retrySuffix(result); this._appendLine(line, prefix); } @@ -99,7 +97,7 @@ class ListReporter extends BaseReporter { const line = test.title + colors.dim(stepSuffix(step)); this._appendLine(line, prefix); } else { - this._updateLine(this._testRows.get(test)!, colors.dim(formatTestTitle(this.config, test, step, false, this._appendTags)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); + this._updateLine(this._testRows.get(test)!, colors.dim(formatTestTitle(this.config, test, step)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); } } @@ -110,12 +108,12 @@ class ListReporter extends BaseReporter { const testIndex = this._resultIndex.get(result) || ''; if (!this._printSteps) { if (isTTY) - this._updateLine(this._testRows.get(test)!, colors.dim(formatTestTitle(this.config, test, step.parent, false, this._appendTags)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); + this._updateLine(this._testRows.get(test)!, colors.dim(formatTestTitle(this.config, test, step.parent)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); return; } const index = this.getStepIndex(testIndex, result, step); - const title = isTTY ? test.title + colors.dim(stepSuffix(step)) : formatTestTitle(this.config, test, step, false, this._appendTags); + const title = isTTY ? test.title + colors.dim(stepSuffix(step)) : formatTestTitle(this.config, test, step); const prefix = this._testPrefix(index, ''); let text = ''; if (step.error) @@ -163,7 +161,7 @@ class ListReporter extends BaseReporter { override onTestEnd(test: TestCase, result: TestResult) { super.onTestEnd(test, result); - const title = formatTestTitle(this.config, test, undefined, false, this._appendTags); + const title = formatTestTitle(this.config, test); let prefix = ''; let text = ''; diff --git a/tests/playwright-test/reporter-base.spec.ts b/tests/playwright-test/reporter-base.spec.ts index 6d6e499605..85ba731bf5 100644 --- a/tests/playwright-test/reporter-base.spec.ts +++ b/tests/playwright-test/reporter-base.spec.ts @@ -418,5 +418,19 @@ for (const useIntermediateMergeReport of [false, true] as const) { expect(result.passed).toBe(1); expect(result.output).toMatch(/\d+ passed \(\d+(\.\d)?(ms|s)\)/); }); + + test('should output tags', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.test.ts': ` + const { test, expect } = require('@playwright/test'); + test('passes', { tag: ['@foo', '@bar'] }, async ({}) => { + expect(0).toBe(0); + }); + `, + }); + const text = result.output; + + expect(text).toContain('passes @foo @bar'); + }); }); -} \ No newline at end of file +} diff --git a/tests/playwright-test/reporter-list.spec.ts b/tests/playwright-test/reporter-list.spec.ts index c8ed723f4f..c57190a5d7 100644 --- a/tests/playwright-test/reporter-list.spec.ts +++ b/tests/playwright-test/reporter-list.spec.ts @@ -258,20 +258,6 @@ for (const useIntermediateMergeReport of [false, true] as const) { expect(text).toContain('1) a.test.ts:3:15 › passes › outer 1.0 › inner 1.1 ──'); expect(result.exitCode).toBe(1); }); - - test('append tags', async ({ runInlineTest }) => { - const result = await runInlineTest({ - 'a.test.ts': ` - const { test, expect } = require('@playwright/test'); - test('passes', { tag: ['@foo', '@bar'] }, async ({}) => { - expect(0).toBe(0); - }); - `, - }, { reporter: 'list', workers: '1' }, { PLAYWRIGHT_LIST_APPEND_TAGS: '1' }); - const text = result.output; - - expect(text).toContain(`${POSITIVE_STATUS_MARK} 1 a.test.ts:3:11 › passes [@foo, @bar]`); - }); }); }