diff --git a/lib/internal/test_runner/reporter/utils.js b/lib/internal/test_runner/reporter/utils.js index d90040b9727..67030680019 100644 --- a/lib/internal/test_runner/reporter/utils.js +++ b/lib/internal/test_runner/reporter/utils.js @@ -73,7 +73,10 @@ function formatTestReport(type, data, showErrorDetails = true, prefix = '', inde let symbol = reporterUnicodeSymbolMap[type] ?? ' '; const { skip, todo, expectFailure } = data; const duration_ms = data.details?.duration_ms ? ` ${colors.gray}(${data.details.duration_ms}ms)${colors.white}` : ''; - let title = `${data.name}${duration_ms}`; + const replayed = data.details?.passed_on_attempt !== undefined ? + ` ${colors.gray}(passed on attempt ${data.details.passed_on_attempt})${colors.white}` : + ''; + let title = `${data.name}${duration_ms}${replayed}`; if (skip !== undefined) { title += ` # ${typeof skip === 'string' && skip.length ? skip : 'SKIP'}`; diff --git a/test/parallel/test-runner-test-rerun-failures.js b/test/parallel/test-runner-test-rerun-failures.js index f6ae8735e9b..3a9249cc522 100644 --- a/test/parallel/test-runner-test-rerun-failures.js +++ b/test/parallel/test-runner-test-rerun-failures.js @@ -157,8 +157,15 @@ test('rerun preserves the original duration on the replayed pass', async () => { const durationFixture = fixtures.path('test-runner', 'rerun-duration.js'); const args = ['--test-rerun-failures', stateFile, durationFixture]; - await common.spawnPromisified(process.execPath, args); - await common.spawnPromisified(process.execPath, args); + const first = await common.spawnPromisified(process.execPath, args); + assert.doesNotMatch(first.stdout, /passed on attempt/, + 'no replay marker should appear on the initial run'); + + const second = await common.spawnPromisified(process.execPath, args); + assert.match(second.stdout, /passing slow test[^\n]*\(passed on attempt 0\)/, + 'spec reporter should mark the replayed test on the retry'); + assert.doesNotMatch(second.stdout, /always failing[^\n]*\(passed on attempt/, + 'the failing test must not show the replay marker'); const raw = JSON.parse(await readFile(stateFile, 'utf8')); const passKey = Object.keys(raw[0]).find((k) => raw[0][k].name === 'passing slow test');