* @param {Number} numberOfWorkers
(numberOfWorkers)
| 452 | * @param {Number} numberOfWorkers |
| 453 | */ |
| 454 | createGroupsOfSuites(numberOfWorkers) { |
| 455 | // If Codecept isn't initialized yet, return empty groups as a safe fallback |
| 456 | if (!this.codecept) return populateGroups(numberOfWorkers) |
| 457 | const files = this.codecept.testFiles |
| 458 | const groups = populateGroups(numberOfWorkers) |
| 459 | |
| 460 | // Create a fresh mocha instance to avoid state pollution |
| 461 | Container.createMocha(this.codecept.config.mocha || {}, this.options) |
| 462 | const mocha = Container.mocha() |
| 463 | mocha.files = files |
| 464 | mocha.loadFiles() |
| 465 | |
| 466 | mocha.suite.suites.forEach(suite => { |
| 467 | const i = indexOfSmallestElement(groups) |
| 468 | suite.tests.forEach(test => { |
| 469 | if (test) { |
| 470 | groups[i].push(test.uid) |
| 471 | } |
| 472 | }) |
| 473 | }) |
| 474 | |
| 475 | // Clean up after collecting test UIDs |
| 476 | mocha.unloadFiles() |
| 477 | |
| 478 | return groups |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * @param {Object} config |
no test coverage detected