@@ -83,6 +83,11 @@ async function runPoolTests() {
8383 initializeListeners ( )
8484 disablePause ( )
8585
86+ // Accumulate results across all tests in pool mode
87+ let consolidatedStats = { passes : 0 , failures : 0 , tests : 0 , pending : 0 , failedHooks : 0 }
88+ let allTests = [ ]
89+ let allFailures = [ ]
90+
8691 // Keep requesting tests until no more available
8792 while ( true ) {
8893 // Request a test assignment
@@ -106,6 +111,22 @@ async function runPoolTests() {
106111 if ( mocha . suite . total ( ) > 0 ) {
107112 // Run the test and complete
108113 await codecept . run ( )
114+
115+ // Accumulate the results from this test run
116+ const result = container . result ( )
117+ consolidatedStats . passes += result . stats . passes || 0
118+ consolidatedStats . failures += result . stats . failures || 0
119+ consolidatedStats . tests += result . stats . tests || 0
120+ consolidatedStats . pending += result . stats . pending || 0
121+ consolidatedStats . failedHooks += result . stats . failedHooks || 0
122+
123+ // Add tests and failures to consolidated collections
124+ if ( result . tests ) {
125+ allTests . push ( ...result . tests )
126+ }
127+ if ( result . failures ) {
128+ allFailures . push ( ...result . failures )
129+ }
109130 }
110131
111132 // Signal test completed and request next
@@ -141,6 +162,17 @@ async function runPoolTests() {
141162 console . error ( 'Teardown error:' , err )
142163 }
143164
165+ // Send final consolidated results for the entire worker
166+ const finalResult = {
167+ stats : consolidatedStats ,
168+ tests : allTests ,
169+ failures : allFailures ,
170+ hasFailed : consolidatedStats . failures > 0
171+ }
172+
173+ sendToParentThread ( { event : event . all . after , workerIndex, data : finalResult } )
174+ sendToParentThread ( { event : event . all . result , workerIndex, data : finalResult } )
175+
144176 // Close worker thread when pool mode is complete
145177 parentPort ?. close ( )
146178}
@@ -220,15 +252,8 @@ function initializeListeners() {
220252 parentPort ?. close ( )
221253 } )
222254 } else {
223- // In pool mode, don't close worker after individual test completion
224- // The worker will close when it receives 'NO_MORE_TESTS' message
225- event . dispatcher . on ( event . all . after , ( ) => {
226- sendToParentThread ( { event : event . all . after , workerIndex, data : container . result ( ) . simplify ( ) } )
227- } )
228- event . dispatcher . on ( event . all . result , ( ) => {
229- sendToParentThread ( { event : event . all . result , workerIndex, data : container . result ( ) . simplify ( ) } )
230- // Don't close parentPort in pool mode - let the pool manager handle worker lifecycle
231- } )
255+ // In pool mode, don't send result events for individual tests
256+ // Results will be sent once when the worker completes all tests
232257 }
233258}
234259
0 commit comments