MCPcopy
hub / github.com/codeceptjs/CodeceptJS / splitTestsByGroups

Method splitTestsByGroups

lib/workers.js:333–350  ·  view source on GitHub ↗

* This splits tests by groups. * Strategy for group split is taken from a constructor's config.by value: * * `config.by` can be: * * - `suite` * - `test` * - `pool` * - function(numberOfWorkers) * * This method can be overridden for a better split.

(numberOfWorkers, config)

Source from the content-addressed store, hash-verified

331 * This method can be overridden for a better split.
332 */
333 splitTestsByGroups(numberOfWorkers, config) {
334 if (isFunction(config.by)) {
335 const createTests = config.by
336 const testGroups = createTests(numberOfWorkers)
337 if (!(testGroups instanceof Array)) {
338 throw new Error('Test group should be an array')
339 }
340 for (const testGroup of testGroups) {
341 this.testGroups.push(convertToMochaTests(testGroup))
342 }
343 } else if (typeof numberOfWorkers === 'number' && numberOfWorkers > 0) {
344 if (config.by === 'pool') {
345 this.createTestPool(numberOfWorkers)
346 } else {
347 this.testGroups = config.by === 'suite' ? this.createGroupsOfSuites(numberOfWorkers) : this.createGroupsOfTests(numberOfWorkers)
348 }
349 }
350 }
351
352 /**
353 * Creates a new worker

Callers 1

_initWorkersMethod · 0.95

Calls 6

createTestPoolMethod · 0.95
createGroupsOfSuitesMethod · 0.95
createGroupsOfTestsMethod · 0.95
isFunctionFunction · 0.90
convertToMochaTestsFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected