codeceptjs 4.0.2-beta.7 → 4.0.2-beta.9

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.
@@ -19,14 +19,25 @@ const stderr = ''
19
19
 
20
20
  const { options, tests, testRoot, workerIndex, poolMode } = workerData
21
21
 
22
- // Global error handlers to prevent worker from hanging
22
+ // Global error handlers to catch critical errors but not test failures
23
23
  process.on('uncaughtException', (err) => {
24
+ // Don't exit on test assertion errors - those are handled by mocha
25
+ if (err.name === 'AssertionError' || err.message?.includes('expected')) {
26
+ console.error(`[Worker ${workerIndex}] Test assertion error (handled by mocha):`, err.message)
27
+ return
28
+ }
24
29
  console.error(`[Worker ${workerIndex}] Uncaught exception:`, err.message)
25
30
  console.error(err.stack)
26
31
  process.exit(1)
27
32
  })
28
33
 
29
34
  process.on('unhandledRejection', (reason, promise) => {
35
+ // Don't exit on test-related rejections
36
+ const msg = reason?.message || String(reason)
37
+ if (msg.includes('expected') || msg.includes('AssertionError')) {
38
+ console.error(`[Worker ${workerIndex}] Test rejection (handled by mocha):`, msg)
39
+ return
40
+ }
30
41
  console.error(`[Worker ${workerIndex}] Unhandled rejection:`, reason)
31
42
  process.exit(1)
32
43
  })
package/lib/workers.js CHANGED
@@ -518,8 +518,24 @@ class Workers extends EventEmitter {
518
518
  // Workers are already running, this is just a placeholder step
519
519
  })
520
520
 
521
+ // Add overall timeout to prevent infinite hanging
522
+ const overallTimeout = setTimeout(() => {
523
+ console.error('[Main] Overall timeout reached (10 minutes). Force terminating remaining workers...')
524
+ workerThreads.forEach(w => {
525
+ try {
526
+ w.terminate()
527
+ } catch (e) {
528
+ // ignore
529
+ }
530
+ })
531
+ this._finishRun()
532
+ }, 600000) // 10 minutes
533
+
521
534
  return new Promise(resolve => {
522
- this.on('end', resolve)
535
+ this.on('end', () => {
536
+ clearTimeout(overallTimeout)
537
+ resolve()
538
+ })
523
539
  })
524
540
  }
525
541
 
@@ -566,6 +582,11 @@ class Workers extends EventEmitter {
566
582
  // Track current test
567
583
  if (message.event === event.test.started && message.data) {
568
584
  currentTest = message.data.title || message.data.fullTitle
585
+ console.log(`[Worker ${message.workerIndex}] Started: ${currentTest}`)
586
+ }
587
+
588
+ if (message.event === event.test.finished && message.data) {
589
+ console.log(`[Worker ${message.workerIndex}] Finished: ${message.data.title || currentTest}`)
569
590
  }
570
591
 
571
592
  output.process(message.workerIndex)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.0.2-beta.7",
3
+ "version": "4.0.2-beta.9",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [