(testGroups, config, testRoot, options, selectedRuns)
| 104 | } |
| 105 | |
| 106 | const createWorkerObjects = (testGroups, config, testRoot, options, selectedRuns) => { |
| 107 | selectedRuns = options && options.all && config.multiple ? Object.keys(config.multiple) : selectedRuns |
| 108 | if (selectedRuns === undefined || !selectedRuns.length || config.multiple === undefined) { |
| 109 | return testGroups.map((tests, index) => { |
| 110 | const workerObj = new WorkerObject(index) |
| 111 | workerObj.addConfig(config) |
| 112 | workerObj.addTests(tests) |
| 113 | workerObj.setTestRoot(testRoot) |
| 114 | workerObj.addOptions(options) |
| 115 | return workerObj |
| 116 | }) |
| 117 | } |
| 118 | const workersToExecute = [] |
| 119 | |
| 120 | const currentOutputFolder = config.output |
| 121 | let currentMochaJunitReporterFile |
| 122 | |
| 123 | if (config.mocha && config.mocha.reporterOptions) { |
| 124 | currentMochaJunitReporterFile = config.mocha.reporterOptions['mocha-junit-reporter'].options.mochaFile |
| 125 | } |
| 126 | |
| 127 | createRuns(selectedRuns, config).forEach(worker => { |
| 128 | const separator = path.sep |
| 129 | const _config = { ...config } |
| 130 | let workerName = worker.name.replace(':', '_') |
| 131 | _config.output = `${currentOutputFolder}${separator}${workerName}` |
| 132 | if (config.mocha && config.mocha.reporterOptions) { |
| 133 | const _tempArray = currentMochaJunitReporterFile.split(separator) |
| 134 | _tempArray.splice( |
| 135 | _tempArray.findIndex(item => item.includes('.xml')), |
| 136 | 0, |
| 137 | workerName, |
| 138 | ) |
| 139 | _config.mocha.reporterOptions['mocha-junit-reporter'].options.mochaFile = _tempArray.join(separator) |
| 140 | } |
| 141 | workerName = worker.getOriginalName() || worker.getName() |
| 142 | const workerConfig = worker.getConfig() |
| 143 | workersToExecute.push(getOverridenConfig(workerName, workerConfig, _config)) |
| 144 | }) |
| 145 | const workers = [] |
| 146 | let index = 0 |
| 147 | testGroups.forEach(tests => { |
| 148 | const testWorkerArray = [] |
| 149 | workersToExecute.forEach(finalConfig => { |
| 150 | const workerObj = new WorkerObject(index++) |
| 151 | workerObj.addConfig(finalConfig) |
| 152 | workerObj.addTests(tests) |
| 153 | workerObj.setTestRoot(testRoot) |
| 154 | workerObj.addOptions(options) |
| 155 | testWorkerArray.push(workerObj) |
| 156 | }) |
| 157 | workers.push(...testWorkerArray) |
| 158 | }) |
| 159 | return workers |
| 160 | } |
| 161 | |
| 162 | const indexOfSmallestElement = groups => { |
| 163 | let i = 0 |
no test coverage detected