Skip to content

Commit 1075552

Browse files
authored
fix: show only verbose or debug mode (#5232)
1 parent 5826298 commit 1075552

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

lib/plugin/htmlReporter.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ module.exports = function (config) {
103103
// Method 1: Check retryNum property (most reliable)
104104
if (test.retryNum && test.retryNum > 0) {
105105
testRetryAttempts.set(testId, test.retryNum)
106-
output.print(`HTML Reporter: Retry count detected (retryNum) for ${test.title}, attempts: ${test.retryNum}`)
106+
output.debug(`HTML Reporter: Retry count detected (retryNum) for ${test.title}, attempts: ${test.retryNum}`)
107107
}
108108
// Method 2: Check currentRetry property
109109
else if (test.currentRetry && test.currentRetry > 0) {
110110
testRetryAttempts.set(testId, test.currentRetry)
111-
output.print(`HTML Reporter: Retry count detected (currentRetry) for ${test.title}, attempts: ${test.currentRetry}`)
111+
output.debug(`HTML Reporter: Retry count detected (currentRetry) for ${test.title}, attempts: ${test.currentRetry}`)
112112
}
113113
// Method 3: Check if this is a retried test
114114
else if (test.retriedTest && test.retriedTest()) {
@@ -119,12 +119,12 @@ module.exports = function (config) {
119119
} else {
120120
testRetryAttempts.set(originalTestId, testRetryAttempts.get(originalTestId) + 1)
121121
}
122-
output.print(`HTML Reporter: Retry detected (retriedTest) for ${originalTest.title}, attempts: ${testRetryAttempts.get(originalTestId)}`)
122+
output.debug(`HTML Reporter: Retry detected (retriedTest) for ${originalTest.title}, attempts: ${testRetryAttempts.get(originalTestId)}`)
123123
}
124124
// Method 4: Check if test has been seen before (indicating a retry)
125125
else if (reportData.tests.some(t => t.id === testId)) {
126126
testRetryAttempts.set(testId, 1) // First retry detected
127-
output.print(`HTML Reporter: Retry detected (duplicate test) for ${test.title}, attempts: 1`)
127+
output.debug(`HTML Reporter: Retry detected (duplicate test) for ${test.title}, attempts: 1`)
128128
}
129129
}
130130
})
@@ -196,20 +196,20 @@ module.exports = function (config) {
196196
if (test.retryNum && test.retryNum > 0) {
197197
retryAttempts = test.retryNum
198198
testRetryAttempts.set(testId, retryAttempts)
199-
output.print(`HTML Reporter: Late retry detection (retryNum) for ${test.title}, attempts: ${retryAttempts}`)
199+
output.debug(`HTML Reporter: Late retry detection (retryNum) for ${test.title}, attempts: ${retryAttempts}`)
200200
} else if (test.currentRetry && test.currentRetry > 0) {
201201
retryAttempts = test.currentRetry
202202
testRetryAttempts.set(testId, retryAttempts)
203-
output.print(`HTML Reporter: Late retry detection (currentRetry) for ${test.title}, attempts: ${retryAttempts}`)
203+
output.debug(`HTML Reporter: Late retry detection (currentRetry) for ${test.title}, attempts: ${retryAttempts}`)
204204
} else if (test._retries && test._retries > 0) {
205205
retryAttempts = test._retries
206206
testRetryAttempts.set(testId, retryAttempts)
207-
output.print(`HTML Reporter: Late retry detection (_retries) for ${test.title}, attempts: ${retryAttempts}`)
207+
output.debug(`HTML Reporter: Late retry detection (_retries) for ${test.title}, attempts: ${retryAttempts}`)
208208
}
209209
}
210210

211211
// Debug logging
212-
output.print(`HTML Reporter: Test finished - ${test.title}, State: ${test.state}, Retries: ${retryAttempts}`)
212+
output.debug(`HTML Reporter: Test finished - ${test.title}, State: ${test.state}, Retries: ${retryAttempts}`)
213213

214214
// Detect if this is a BDD/Gherkin test
215215
const isBddTest = isBddGherkinTest(test, currentSuite)
@@ -222,7 +222,7 @@ module.exports = function (config) {
222222
const currentlyFailed = test.state === 'failed'
223223

224224
// Debug artifacts collection (but don't process them yet - screenshots may not be ready)
225-
output.print(`HTML Reporter: Test ${test.title} artifacts at test.finished: ${JSON.stringify(test.artifacts)}`)
225+
output.debug(`HTML Reporter: Test ${test.title} artifacts at test.finished: ${JSON.stringify(test.artifacts)}`)
226226

227227
const testData = {
228228
...test,
@@ -244,11 +244,11 @@ module.exports = function (config) {
244244
if (existingTestIndex >= 0) {
245245
// Update existing test with final result (including failed state)
246246
reportData.tests[existingTestIndex] = testData
247-
output.print(`HTML Reporter: Updated existing test - ${test.title}, Final state: ${test.state}`)
247+
output.debug(`HTML Reporter: Updated existing test - ${test.title}, Final state: ${test.state}`)
248248
} else {
249249
// Add new test
250250
reportData.tests.push(testData)
251-
output.print(`HTML Reporter: Added new test - ${test.title}, State: ${test.state}`)
251+
output.debug(`HTML Reporter: Added new test - ${test.title}, State: ${test.state}`)
252252
}
253253

254254
// Track retry information - only add if there were actual retries AND the test failed at some point
@@ -262,7 +262,7 @@ module.exports = function (config) {
262262
if (retryAttempts === 0 && existingRetryIndex >= 0) {
263263
retryAttempts = reportData.retries[existingRetryIndex].attempts + 1
264264
testRetryAttempts.set(testId, retryAttempts)
265-
output.print(`HTML Reporter: Incremented retry count for duplicate test ${test.title}, attempts: ${retryAttempts}`)
265+
output.debug(`HTML Reporter: Incremented retry count for duplicate test ${test.title}, attempts: ${retryAttempts}`)
266266
}
267267

268268
// Remove existing retry info for this test and add updated one
@@ -274,7 +274,7 @@ module.exports = function (config) {
274274
finalState: test.state,
275275
duration: test.duration || 0,
276276
})
277-
output.print(`HTML Reporter: Added retry info for ${test.title}, attempts: ${retryAttempts}, state: ${test.state}`)
277+
output.debug(`HTML Reporter: Added retry info for ${test.title}, attempts: ${retryAttempts}, state: ${test.state}`)
278278
}
279279

280280
// Fallback: If this test already exists and either failed before or is failing now, it's a retry
@@ -288,7 +288,7 @@ module.exports = function (config) {
288288
finalState: test.state,
289289
duration: test.duration || 0,
290290
})
291-
output.print(`HTML Reporter: Fallback retry detection for failed test ${test.title}, attempts: ${fallbackAttempts}`)
291+
output.debug(`HTML Reporter: Fallback retry detection for failed test ${test.title}, attempts: ${fallbackAttempts}`)
292292
}
293293
})
294294

@@ -298,40 +298,40 @@ module.exports = function (config) {
298298
reportData.duration = reportData.endTime - reportData.startTime
299299

300300
// Process artifacts now that all async tasks (including screenshots) are complete
301-
output.print(`HTML Reporter: Processing artifacts for ${reportData.tests.length} tests after all async tasks complete`)
301+
output.debug(`HTML Reporter: Processing artifacts for ${reportData.tests.length} tests after all async tasks complete`)
302302

303303
reportData.tests.forEach(test => {
304304
const originalArtifacts = test.artifacts
305305
let collectedArtifacts = []
306306

307-
output.print(`HTML Reporter: Processing test "${test.title}" (ID: ${test.id})`)
308-
output.print(`HTML Reporter: Test ${test.title} final artifacts: ${JSON.stringify(originalArtifacts)}`)
307+
output.debug(`HTML Reporter: Processing test "${test.title}" (ID: ${test.id})`)
308+
output.debug(`HTML Reporter: Test ${test.title} final artifacts: ${JSON.stringify(originalArtifacts)}`)
309309

310310
if (originalArtifacts) {
311311
if (Array.isArray(originalArtifacts)) {
312312
collectedArtifacts = originalArtifacts
313-
output.print(`HTML Reporter: Using array artifacts: ${collectedArtifacts.length} items`)
313+
output.debug(`HTML Reporter: Using array artifacts: ${collectedArtifacts.length} items`)
314314
} else if (typeof originalArtifacts === 'object') {
315315
// Convert object properties to array (screenshotOnFail plugin format)
316316
collectedArtifacts = Object.values(originalArtifacts).filter(artifact => artifact)
317-
output.print(`HTML Reporter: Converted artifacts object to array: ${collectedArtifacts.length} items`)
318-
output.print(`HTML Reporter: Converted artifacts: ${JSON.stringify(collectedArtifacts)}`)
317+
output.debug(`HTML Reporter: Converted artifacts object to array: ${collectedArtifacts.length} items`)
318+
output.debug(`HTML Reporter: Converted artifacts: ${JSON.stringify(collectedArtifacts)}`)
319319
}
320320
}
321321

322322
// Only use filesystem fallback if no artifacts found from screenshotOnFail plugin
323323
if (collectedArtifacts.length === 0 && test.state === 'failed') {
324-
output.print(`HTML Reporter: No artifacts from plugin, trying filesystem for test "${test.title}"`)
324+
output.debug(`HTML Reporter: No artifacts from plugin, trying filesystem for test "${test.title}"`)
325325
collectedArtifacts = collectScreenshotsFromFilesystem(test, test.id)
326-
output.print(`HTML Reporter: Collected ${collectedArtifacts.length} screenshots from filesystem for failed test "${test.title}"`)
326+
output.debug(`HTML Reporter: Collected ${collectedArtifacts.length} screenshots from filesystem for failed test "${test.title}"`)
327327
if (collectedArtifacts.length > 0) {
328-
output.print(`HTML Reporter: Filesystem screenshots for "${test.title}": ${JSON.stringify(collectedArtifacts)}`)
328+
output.debug(`HTML Reporter: Filesystem screenshots for "${test.title}": ${JSON.stringify(collectedArtifacts)}`)
329329
}
330330
}
331331

332332
// Update test with processed artifacts
333333
test.artifacts = collectedArtifacts
334-
output.print(`HTML Reporter: Final artifacts for "${test.title}": ${JSON.stringify(test.artifacts)}`)
334+
output.debug(`HTML Reporter: Final artifacts for "${test.title}": ${JSON.stringify(test.artifacts)}`)
335335
})
336336

337337
// Calculate stats from our collected test data instead of using result.stats
@@ -384,19 +384,19 @@ module.exports = function (config) {
384384
}
385385

386386
// Debug logging for final stats
387-
output.print(`HTML Reporter: Calculated stats - Tests: ${reportData.stats.tests}, Passes: ${reportData.stats.passes}, Failures: ${reportData.stats.failures}`)
388-
output.print(`HTML Reporter: Collected ${reportData.tests.length} tests in reportData`)
389-
output.print(`HTML Reporter: Failures array has ${reportData.failures.length} items`)
390-
output.print(`HTML Reporter: Retries array has ${reportData.retries.length} items`)
391-
output.print(`HTML Reporter: testRetryAttempts Map size: ${testRetryAttempts.size}`)
387+
output.debug(`HTML Reporter: Calculated stats - Tests: ${reportData.stats.tests}, Passes: ${reportData.stats.passes}, Failures: ${reportData.stats.failures}`)
388+
output.debug(`HTML Reporter: Collected ${reportData.tests.length} tests in reportData`)
389+
output.debug(`HTML Reporter: Failures array has ${reportData.failures.length} items`)
390+
output.debug(`HTML Reporter: Retries array has ${reportData.retries.length} items`)
391+
output.debug(`HTML Reporter: testRetryAttempts Map size: ${testRetryAttempts.size}`)
392392

393393
// Log retry attempts map contents
394394
for (const [testId, attempts] of testRetryAttempts.entries()) {
395-
output.print(`HTML Reporter: testRetryAttempts - ${testId}: ${attempts} attempts`)
395+
output.debug(`HTML Reporter: testRetryAttempts - ${testId}: ${attempts} attempts`)
396396
}
397397

398398
reportData.tests.forEach(test => {
399-
output.print(`HTML Reporter: Test in reportData - ${test.title}, State: ${test.state}, Retries: ${test.retryAttempts}`)
399+
output.debug(`HTML Reporter: Test in reportData - ${test.title}, State: ${test.state}, Retries: ${test.retryAttempts}`)
400400
})
401401

402402
// Check if running with workers

0 commit comments

Comments
 (0)