GeezerVison is showing github.com — test_runner: show replayed-from-attempt hint in spec reporter · nodejs/node@288c320
File tree
Expand file treeCollapse file tree
Open diff view settings
lib/internal/test_runner/reporter
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/test_runner/reporter/utils.js +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,7 +73,10 @@ function formatTestReport(type, data, showErrorDetails = true, prefix = '', inde |
73 | 73 | let symbol = reporterUnicodeSymbolMap[type] ?? ' '; |
74 | 74 | const { skip, todo, expectFailure } = data; |
75 | 75 | 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}`; |
77 | 80 |
|
78 | 81 | if (skip !== undefined) { |
79 | 82 | title += ` # ${typeof skip === 'string' && skip.length ? skip : 'SKIP'}`; |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-runner-test-rerun-failures.js +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -157,8 +157,15 @@ test('rerun preserves the original duration on the replayed pass', async () => { |
157 | 157 | const durationFixture = fixtures.path('test-runner', 'rerun-duration.js'); |
158 | 158 | const args = ['--test-rerun-failures', stateFile, durationFixture]; |
159 | 159 |
|
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'); |
162 | 169 |
|
163 | 170 | const raw = JSON.parse(await readFile(stateFile, 'utf8')); |
164 | 171 | const passKey = Object.keys(raw[0]).find((k) => raw[0][k].name === 'passing slow test'); |
|