Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/playwright/src/reporters/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ class ListReporter extends TerminalReporter {
const wasPaused = this._paused.delete(result);
if (!wasPaused)
this._updateTestLine(test, result);
if (!wasPaused && this._printFailuresInline && !this.willRetry(test) && (test.outcome() === 'flaky' || test.outcome() === 'unexpected' || result.status === 'interrupted'))
const isFailure = result.status !== 'skipped' && result.status !== test.expectedStatus;
if (!wasPaused && this._printFailuresInline && isFailure)
this._printFailure(test);
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions tests/playwright-test/reporter-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,34 @@ for (const useIntermediateMergeReport of [false, true] as const) {
expect(result.exitCode).toBe(1);
});

test('print failures inline for a non-retriable error', async ({ runInlineTest }) => {
// A missing snapshot fails the test but is not retried. The reporter must
// still print the failure inline, even though the retry budget is not exhausted.
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
reporter: [['list', { printFailuresInline: true }]],
retries: 1,
workers: 1,
};
`,
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('missing snapshot', async ({}) => {
expect('actual').toMatchSnapshot('foo.txt');
});
`,
});
const text = result.output;
const failureHeader = '1) a.test.ts:3:15 › missing snapshot';
const failureIndex = text.indexOf(failureHeader);
expect(failureIndex, 'failure should be printed inline').not.toBe(-1);
expect(text.indexOf(`A snapshot doesn't exist`, failureIndex)).toBeGreaterThan(failureIndex);
// It must not be retried, so there is exactly one failure block.
expect(text.indexOf(failureHeader, failureIndex + 1)).toBe(-1);
expect(result.exitCode).toBe(1);
});

test('print stdio', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `
Expand Down
Loading