* 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)
| 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 |
no test coverage detected