Skip to content

Commit a646c93

Browse files
MoLowaduh95
authored andcommitted
test_runner: show replayed-from-attempt hint in spec reporter
Signed-off-by: Moshe Atlow <moshe@atlow.co.il> PR-URL: #63429 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent b1fa59c commit a646c93

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

lib/internal/test_runner/reporter/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ function formatTestReport(type, data, showErrorDetails = true, prefix = '', inde
7373
let symbol = reporterUnicodeSymbolMap[type] ?? ' ';
7474
const { skip, todo, expectFailure } = data;
7575
const duration_ms = data.details?.duration_ms ? ` ${colors.gray}(${data.details.duration_ms}ms)${colors.white}` : '';
76-
let title = `${data.name}${duration_ms}`;
76+
const replayed = data.details?.passed_on_attempt !== undefined ?
77+
` ${colors.gray}(passed on attempt ${data.details.passed_on_attempt})${colors.white}` :
78+
'';
79+
let title = `${data.name}${duration_ms}${replayed}`;
7780

7881
if (skip !== undefined) {
7982
title += ` # ${typeof skip === 'string' && skip.length ? skip : 'SKIP'}`;

test/parallel/test-runner-test-rerun-failures.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,15 @@ test('rerun preserves the original duration on the replayed pass', async () => {
157157
const durationFixture = fixtures.path('test-runner', 'rerun-duration.js');
158158
const args = ['--test-rerun-failures', stateFile, durationFixture];
159159

160-
await common.spawnPromisified(process.execPath, args);
161-
await common.spawnPromisified(process.execPath, args);
160+
const first = await common.spawnPromisified(process.execPath, args);
161+
assert.doesNotMatch(first.stdout, /passed on attempt/,
162+
'no replay marker should appear on the initial run');
163+
164+
const second = await common.spawnPromisified(process.execPath, args);
165+
assert.match(second.stdout, /passing slow test[^\n]*\(passed on attempt 0\)/,
166+
'spec reporter should mark the replayed test on the retry');
167+
assert.doesNotMatch(second.stdout, /always failing[^\n]*\(passed on attempt/,
168+
'the failing test must not show the replay marker');
162169

163170
const raw = JSON.parse(await readFile(stateFile, 'utf8'));
164171
const passKey = Object.keys(raw[0]).find((k) => raw[0][k].name === 'passing slow test');

0 commit comments

Comments
 (0)