MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / createGroupsOfSuites

Method createGroupsOfSuites

lib/workers.js:454–479  ·  view source on GitHub ↗

* @param {Number} numberOfWorkers

(numberOfWorkers)

Source from the content-addressed store, hash-verified

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

Callers 2

splitTestsByGroupsMethod · 0.95
worker_test.jsFile · 0.80

Calls 5

populateGroupsFunction · 0.85
indexOfSmallestElementFunction · 0.85
createMochaMethod · 0.80
mochaMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected