Skip to content

Commit 17c003c

Browse files
authored
fix(reporter): print inline failure for non-retriable errors (#41026)
1 parent dfe5ab5 commit 17c003c

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/playwright/src/reporters/list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ class ListReporter extends TerminalReporter {
194194
const wasPaused = this._paused.delete(result);
195195
if (!wasPaused)
196196
this._updateTestLine(test, result);
197-
if (!wasPaused && this._printFailuresInline && !this.willRetry(test) && (test.outcome() === 'flaky' || test.outcome() === 'unexpected' || result.status === 'interrupted'))
197+
const isFailure = result.status !== 'skipped' && result.status !== test.expectedStatus;
198+
if (!wasPaused && this._printFailuresInline && isFailure)
198199
this._printFailure(test);
199200
}
200201

9.77 KB
Loading

tests/playwright-test/reporter-list.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,34 @@ for (const useIntermediateMergeReport of [false, true] as const) {
288288
expect(result.exitCode).toBe(1);
289289
});
290290

291+
test('print failures inline for a non-retriable error', async ({ runInlineTest }) => {
292+
// A missing snapshot fails the test but is not retried. The reporter must
293+
// still print the failure inline, even though the retry budget is not exhausted.
294+
const result = await runInlineTest({
295+
'playwright.config.ts': `
296+
module.exports = {
297+
reporter: [['list', { printFailuresInline: true }]],
298+
retries: 1,
299+
workers: 1,
300+
};
301+
`,
302+
'a.test.ts': `
303+
import { test, expect } from '@playwright/test';
304+
test('missing snapshot', async ({}) => {
305+
expect('actual').toMatchSnapshot('foo.txt');
306+
});
307+
`,
308+
});
309+
const text = result.output;
310+
const failureHeader = '1) a.test.ts:3:15 › missing snapshot';
311+
const failureIndex = text.indexOf(failureHeader);
312+
expect(failureIndex, 'failure should be printed inline').not.toBe(-1);
313+
expect(text.indexOf(`A snapshot doesn't exist`, failureIndex)).toBeGreaterThan(failureIndex);
314+
// It must not be retried, so there is exactly one failure block.
315+
expect(text.indexOf(failureHeader, failureIndex + 1)).toBe(-1);
316+
expect(result.exitCode).toBe(1);
317+
});
318+
291319
test('print stdio', async ({ runInlineTest }) => {
292320
const result = await runInlineTest({
293321
'a.test.ts': `

0 commit comments

Comments
 (0)