codeceptjs 4.0.2-beta.5 → 4.0.2-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/workers.js +24 -1
- package/package.json +1 -1
package/lib/workers.js
CHANGED
|
@@ -545,12 +545,16 @@ class Workers extends EventEmitter {
|
|
|
545
545
|
|
|
546
546
|
// Track last activity time to detect hanging workers
|
|
547
547
|
let lastActivity = Date.now()
|
|
548
|
+
let currentTest = null
|
|
548
549
|
const workerTimeout = 300000 // 5 minutes
|
|
549
550
|
|
|
550
551
|
const timeoutChecker = setInterval(() => {
|
|
551
552
|
const elapsed = Date.now() - lastActivity
|
|
552
553
|
if (elapsed > workerTimeout) {
|
|
553
554
|
console.error(`[Main] Worker appears to be hanging (no activity for ${Math.floor(elapsed/1000)}s). Terminating...`)
|
|
555
|
+
if (currentTest) {
|
|
556
|
+
console.error(`[Main] Last test: ${currentTest}`)
|
|
557
|
+
}
|
|
554
558
|
clearInterval(timeoutChecker)
|
|
555
559
|
worker.terminate()
|
|
556
560
|
}
|
|
@@ -558,6 +562,12 @@ class Workers extends EventEmitter {
|
|
|
558
562
|
|
|
559
563
|
worker.on('message', message => {
|
|
560
564
|
lastActivity = Date.now() // Update activity timestamp
|
|
565
|
+
|
|
566
|
+
// Track current test
|
|
567
|
+
if (message.event === event.test.started && message.data) {
|
|
568
|
+
currentTest = message.data.title || message.data.fullTitle
|
|
569
|
+
}
|
|
570
|
+
|
|
561
571
|
output.process(message.workerIndex)
|
|
562
572
|
|
|
563
573
|
// Handle test requests for pool mode
|
|
@@ -675,6 +685,9 @@ class Workers extends EventEmitter {
|
|
|
675
685
|
|
|
676
686
|
worker.on('error', err => {
|
|
677
687
|
console.error(`[Main] Worker error:`, err.message || err)
|
|
688
|
+
if (currentTest) {
|
|
689
|
+
console.error(`[Main] Failed during test: ${currentTest}`)
|
|
690
|
+
}
|
|
678
691
|
this.errors.push(err)
|
|
679
692
|
})
|
|
680
693
|
|
|
@@ -684,7 +697,14 @@ class Workers extends EventEmitter {
|
|
|
684
697
|
|
|
685
698
|
if (code !== 0) {
|
|
686
699
|
console.error(`[Main] Worker exited with code ${code}`)
|
|
700
|
+
if (currentTest) {
|
|
701
|
+
console.error(`[Main] Last test running: ${currentTest}`)
|
|
702
|
+
}
|
|
703
|
+
// Mark as failed
|
|
704
|
+
process.exitCode = 1
|
|
687
705
|
}
|
|
706
|
+
|
|
707
|
+
console.log(`[Main] Workers closed: ${this.closedWorkers}/${this.numberOfWorkers}`)
|
|
688
708
|
|
|
689
709
|
if (this.isPoolMode) {
|
|
690
710
|
// Pool mode: finish when all workers have exited and no more tests
|
|
@@ -699,8 +719,9 @@ class Workers extends EventEmitter {
|
|
|
699
719
|
}
|
|
700
720
|
|
|
701
721
|
_finishRun() {
|
|
722
|
+
console.log('[Main] Finishing test run...')
|
|
702
723
|
event.dispatcher.emit(event.workers.after, { tests: this.workers.map(worker => worker.tests) })
|
|
703
|
-
if (Container.result().hasFailed) {
|
|
724
|
+
if (Container.result().hasFailed || this.errors.length > 0) {
|
|
704
725
|
process.exitCode = 1
|
|
705
726
|
} else {
|
|
706
727
|
process.exitCode = 0
|
|
@@ -740,8 +761,10 @@ class Workers extends EventEmitter {
|
|
|
740
761
|
this._testStates.clear()
|
|
741
762
|
}
|
|
742
763
|
|
|
764
|
+
console.log('[Main] Emitting final results...')
|
|
743
765
|
this.emit(event.all.result, Container.result())
|
|
744
766
|
event.dispatcher.emit(event.workers.result, Container.result())
|
|
767
|
+
console.log('[Main] Emitting end event...')
|
|
745
768
|
this.emit('end') // internal event
|
|
746
769
|
}
|
|
747
770
|
|