Skip to content

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

fix(test-runner): stop line reporter from mislabeling passing tests as retries (#39684)

Matt Van Horn3321ef117c55
diff --git a/packages/playwright/src/reporters/line.ts b/packages/playwright/src/reporters/line.ts
index 3f7b2b6313..81f408f86a 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/playwright-test/reporter-line.spec.ts b/tests/playwright-test/reporter-line.spec.ts
index 1a686bf42e..61b20cde9b 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': `