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

Method createGroupsOfTests

lib/workers.js:367–393  ·  view source on GitHub ↗

* @param {Number} numberOfWorkers

(numberOfWorkers)

Source from the content-addressed store, hash-verified

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

Callers 1

splitTestsByGroupsMethod · 0.95

Calls 4

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

Tested by

no test coverage detected