Skip to content

Commit 288c320

Browse files
MoLowsxa
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 904bdf5 commit 288c320

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
letsymbol=reporterUnicodeSymbolMap[type]??' ';
7474
const{ skip, todo, expectFailure }=data;
7575
constduration_ms=data.details?.duration_ms ? ` ${colors.gray}(${data.details.duration_ms}ms)${colors.white}` : '';
76-
lettitle=`${data.name}${duration_ms}`;
76+
constreplayed=data.details?.passed_on_attempt!==undefined ?
77+
` ${colors.gray}(passed on attempt ${data.details.passed_on_attempt})${colors.white}` :
78+
'';
79+
lettitle=`${data.name}${duration_ms}${replayed}`;
7780

7881
if(skip!==undefined){
7982
title+=` # ${typeofskip==='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
constdurationFixture=fixtures.path('test-runner','rerun-duration.js');
158158
constargs=['--test-rerun-failures',stateFile,durationFixture];
159159

160-
awaitcommon.spawnPromisified(process.execPath,args);
161-
awaitcommon.spawnPromisified(process.execPath,args);
160+
constfirst=awaitcommon.spawnPromisified(process.execPath,args);
161+
assert.doesNotMatch(first.stdout,/passedonattempt/,
162+
'no replay marker should appear on the initial run');
163+
164+
constsecond=awaitcommon.spawnPromisified(process.execPath,args);
165+
assert.match(second.stdout,/passingslowtest[^\n]*\(passedonattempt0\)/,
166+
'spec reporter should mark the replayed test on the retry');
167+
assert.doesNotMatch(second.stdout,/alwaysfailing[^\n]*\(passedonattempt/,
168+
'the failing test must not show the replay marker');
162169

163170
constraw=JSON.parse(awaitreadFile(stateFile,'utf8'));
164171
constpassKey=Object.keys(raw[0]).find((k)=>raw[0][k].name==='passing slow test');

0 commit comments

Comments
 (0)