codeceptjs 4.0.2-beta.1 → 4.0.2-beta.2

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.
@@ -336,6 +336,26 @@ function filterTests() {
336
336
  mocha.files = files
337
337
  mocha.loadFiles()
338
338
 
339
+ // Debug logging to help diagnose test filtering issues
340
+ if (options.debug || options.verbose) {
341
+ const allLoadedTests = [];
342
+ mocha.suite.eachTest(test => {
343
+ if (test) {
344
+ allLoadedTests.push({ uid: test.uid, title: test.fullTitle() });
345
+ }
346
+ });
347
+
348
+ console.log(`[Worker ${workerIndex}] Loaded ${allLoadedTests.length} tests, expecting ${tests.length} tests`);
349
+
350
+ const loadedUids = new Set(allLoadedTests.map(t => t.uid));
351
+ const missingTests = tests.filter(uid => !loadedUids.has(uid));
352
+
353
+ if (missingTests.length > 0) {
354
+ console.log(`[Worker ${workerIndex}] WARNING: ${missingTests.length} assigned tests not found in loaded files`);
355
+ console.log(`[Worker ${workerIndex}] Missing UIDs:`, missingTests);
356
+ }
357
+ }
358
+
339
359
  // Recursively filter tests in all suites (including nested ones)
340
360
  const filterSuiteTests = (suite) => {
341
361
  suite.tests = suite.tests.filter(test => tests.indexOf(test.uid) >= 0)
@@ -347,6 +367,13 @@ function filterTests() {
347
367
  for (const suite of mocha.suite.suites) {
348
368
  filterSuiteTests(suite)
349
369
  }
370
+
371
+ // Verify final test count
372
+ if (options.debug || options.verbose) {
373
+ let finalCount = 0;
374
+ mocha.suite.eachTest(() => finalCount++);
375
+ console.log(`[Worker ${workerIndex}] After filtering: ${finalCount} tests will run`);
376
+ }
350
377
  }
351
378
 
352
379
  function initializeListeners() {
package/lib/workers.js CHANGED
@@ -370,6 +370,9 @@ class Workers extends EventEmitter {
370
370
  // If Codecept isn't initialized yet, return empty groups as a safe fallback
371
371
  if (!this.codecept) return populateGroups(numberOfWorkers)
372
372
  const files = this.codecept.testFiles
373
+
374
+ // Create a fresh mocha instance to avoid state pollution
375
+ Container.createMocha(this.codecept.config.mocha || {}, this.options)
373
376
  const mocha = Container.mocha()
374
377
  mocha.files = files
375
378
  mocha.loadFiles()
@@ -384,6 +387,10 @@ class Workers extends EventEmitter {
384
387
  groupCounter++
385
388
  }
386
389
  })
390
+
391
+ // Clean up after collecting test UIDs
392
+ mocha.unloadFiles()
393
+
387
394
  return groups
388
395
  }
389
396
 
@@ -452,9 +459,12 @@ class Workers extends EventEmitter {
452
459
  const files = this.codecept.testFiles
453
460
  const groups = populateGroups(numberOfWorkers)
454
461
 
462
+ // Create a fresh mocha instance to avoid state pollution
463
+ Container.createMocha(this.codecept.config.mocha || {}, this.options)
455
464
  const mocha = Container.mocha()
456
465
  mocha.files = files
457
466
  mocha.loadFiles()
467
+
458
468
  mocha.suite.suites.forEach(suite => {
459
469
  const i = indexOfSmallestElement(groups)
460
470
  suite.tests.forEach(test => {
@@ -463,6 +473,10 @@ class Workers extends EventEmitter {
463
473
  }
464
474
  })
465
475
  })
476
+
477
+ // Clean up after collecting test UIDs
478
+ mocha.unloadFiles()
479
+
466
480
  return groups
467
481
  }
468
482
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.0.2-beta.1",
3
+ "version": "4.0.2-beta.2",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [