* @param {Number} numberOfWorkers
(numberOfWorkers)
| 365 | * @param {Number} numberOfWorkers |
| 366 | */ |
| 367 | createGroupsOfTests(numberOfWorkers) { |
| 368 | // If Codecept isn't initialized yet, return empty groups as a safe fallback |
| 369 | if (!this.codecept) return populateGroups(numberOfWorkers) |
| 370 | const files = this.codecept.testFiles |
| 371 | |
| 372 | // Create a fresh mocha instance to avoid state pollution |
| 373 | Container.createMocha(this.codecept.config.mocha || {}, this.options) |
| 374 | const mocha = Container.mocha() |
| 375 | mocha.files = files |
| 376 | mocha.loadFiles() |
| 377 | |
| 378 | const groups = populateGroups(numberOfWorkers) |
| 379 | let groupCounter = 0 |
| 380 | |
| 381 | mocha.suite.eachTest(test => { |
| 382 | const i = groupCounter % groups.length |
| 383 | if (test) { |
| 384 | groups[i].push(test.uid) |
| 385 | groupCounter++ |
| 386 | } |
| 387 | }) |
| 388 | |
| 389 | // Clean up after collecting test UIDs |
| 390 | mocha.unloadFiles() |
| 391 | |
| 392 | return groups |
| 393 | } |
| 394 | |
| 395 | /** |
| 396 | * @param {Number} numberOfWorkers |
no test coverage detected