Skip to content

Commit db7d0fc

Browse files
authored
fix: wrong stats when running with workers (#5215)
* fix: wrong stats when running with workers * fix: failed runner tests
1 parent f5a9157 commit db7d0fc

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

lib/command/workers/runTests.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,49 @@ const Codecept = require(process.env.CODECEPT_CLASS_PATH || '../../codecept')
2323
const { options, tests, testRoot, workerIndex, poolMode } = workerData
2424

2525
// hide worker output
26-
if (!options.debug && !options.verbose)
26+
// In pool mode, only suppress output if debug is NOT enabled
27+
// In regular mode, hide result output but allow step output in verbose/debug
28+
if (poolMode && !options.debug) {
29+
// In pool mode without debug, suppress only result summaries and failures, but allow Scenario Steps
30+
const originalWrite = process.stdout.write
31+
process.stdout.write = string => {
32+
// Always allow Scenario Steps output
33+
if (string.includes('Scenario Steps:')) {
34+
return originalWrite.call(process.stdout, string)
35+
}
36+
if (string.includes(' FAIL |') || string.includes(' OK |') || string.includes('-- FAILURES:') || string.includes('AssertionError:') || string.includes('◯ File:')) {
37+
return true
38+
}
39+
return originalWrite.call(process.stdout, string)
40+
}
41+
} else if (!poolMode && !options.debug && !options.verbose) {
2742
process.stdout.write = string => {
2843
stdout += string
2944
return true
3045
}
46+
} else {
47+
// In verbose/debug mode for test/suite modes, show step details
48+
// but suppress individual worker result summaries to avoid duplicate output
49+
const originalWrite = process.stdout.write
50+
const originalConsoleLog = console.log
51+
52+
process.stdout.write = string => {
53+
// Suppress individual worker result summaries and failure reports
54+
if (string.includes(' FAIL |') || string.includes(' OK |') || string.includes('-- FAILURES:') || string.includes('AssertionError:') || string.includes('◯ File:') || string.includes('◯ Scenario Steps:')) {
55+
return true
56+
}
57+
return originalWrite.call(process.stdout, string)
58+
}
59+
60+
// Override console.log to catch result summaries
61+
console.log = (...args) => {
62+
const fullMessage = args.join(' ')
63+
if (fullMessage.includes(' FAIL |') || fullMessage.includes(' OK |') || fullMessage.includes('-- FAILURES:')) {
64+
return
65+
}
66+
return originalConsoleLog.apply(console, args)
67+
}
68+
}
3169

3270
const overrideConfigs = tryOrDefault(() => JSON.parse(options.override), {})
3371

0 commit comments

Comments
 (0)