diff --git a/packages/playwright/src/reporters/line.ts b/packages/playwright/src/reporters/line.ts index 3f7b2b631308c..81f408f86a44f 100644 --- a/packages/playwright/src/reporters/line.ts +++ b/packages/playwright/src/reporters/line.ts @@ -112,7 +112,7 @@ class LineReporter extends TerminalReporter { } private _updateLine(test: TestCase, result: TestResult, step?: TestStep) { - const retriesPrefix = this.totalTestCount < this._current ? ` (retries)` : ``; + const retriesPrefix = result.retry ? ` (retries)` : ``; const prefix = `[${this._current}/${this.totalTestCount}]${retriesPrefix} `; const currentRetrySuffix = result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : ''; const title = this.formatTestTitle(test, step) + currentRetrySuffix; diff --git a/tests/page/page-basic.spec.ts b/tests/page/page-basic.spec.ts index cf923d747a469..e14c4a7bb7e2f 100644 --- a/tests/page/page-basic.spec.ts +++ b/tests/page/page-basic.spec.ts @@ -93,7 +93,7 @@ it('page.title should not throw during navigation', async ({ page, server }) => promise, ]); expect(typeof titleOrError).toBe('string'); - expect(titleOrError).toMatch(/^(Loading http.*title.html|hello|Woof-Woof)$/); + expect(titleOrError).toMatch(/^(hello|Loading http.*title.html||Woof-Woof)$/); await expect(page).toHaveTitle('Woof-Woof'); }); diff --git a/tests/playwright-test/reporter-line.spec.ts b/tests/playwright-test/reporter-line.spec.ts index 1a686bf42e45a..61b20cde9b08c 100644 --- a/tests/playwright-test/reporter-line.spec.ts +++ b/tests/playwright-test/reporter-line.spec.ts @@ -44,6 +44,26 @@ for (const useIntermediateMergeReport of [false, true] as const) { expect(result.exitCode).toBe(1); }); + test('should not label passing tests as retries', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.test.js': ` + const { test, expect } = require('@playwright/test'); + test('failing', async ({}) => { + expect(1).toBe(0); + }); + test('passing', async ({}) => { + expect(1).toBe(1); + }); + `, + }, { retries: 1, reporter: 'line' }); + const text = result.output; + expect(text).toContain('[1/2] a.test.js:3:11 › failing'); + expect(text).toContain('a.test.js:3:11 › failing (retry #1)'); + expect(text).toContain('[3/2] a.test.js:6:11 › passing'); + expect(text).not.toContain('(retries) a.test.js:6:11 › passing'); + expect(result.exitCode).toBe(1); + }); + test('render flaky', async ({ runInlineTest }) => { const result = await runInlineTest({ 'a.test.js': `