* @param {object} options run options * @param {EXPECTED_ANY[]} options.optionsArr webpack options array * @param {string} options.outputDirectory output directory * @param {EXPECTED_ANY} options.testConfig test config * @param {{ name: string }} options.category test category * @param {st
({
optionsArr,
outputDirectory,
testConfig,
category,
testName,
setupRunner,
getBundlePaths
})
| 152 | * @returns {{ filesCount: number, results: EXPECTED_ANY[] }} files count and results |
| 153 | */ |
| 154 | static runBundles({ |
| 155 | optionsArr, |
| 156 | outputDirectory, |
| 157 | testConfig, |
| 158 | category, |
| 159 | testName, |
| 160 | setupRunner, |
| 161 | getBundlePaths |
| 162 | }) { |
| 163 | let filesCount = 0; |
| 164 | const results = []; |
| 165 | for (let i = 0; i < optionsArr.length; i++) { |
| 166 | const options = optionsArr[i]; |
| 167 | let found = false; |
| 168 | // universal targets run the same bundle once per concrete environment; |
| 169 | // the `"universal"` preset expands to web + node. |
| 170 | let targets = [options.target]; |
| 171 | if (TestRunner.isUniversalTarget(options)) { |
| 172 | targets = Array.isArray(options.target) |
| 173 | ? options.target |
| 174 | : ["web", "node"]; |
| 175 | } |
| 176 | |
| 177 | for (const target of targets) { |
| 178 | const runner = new TestRunner({ |
| 179 | target, |
| 180 | outputDirectory, |
| 181 | testMeta: { |
| 182 | category: category.name, |
| 183 | name: testName, |
| 184 | round: i |
| 185 | }, |
| 186 | testConfig, |
| 187 | webpackOptions: options |
| 188 | }); |
| 189 | setupRunner({ |
| 190 | runner, |
| 191 | index: i, |
| 192 | target |
| 193 | }); |
| 194 | const bundlePaths = getBundlePaths(i, options, runner); |
| 195 | if (bundlePaths) { |
| 196 | const paths = Array.isArray(bundlePaths) |
| 197 | ? bundlePaths |
| 198 | : [bundlePaths]; |
| 199 | for (const p of paths) { |
| 200 | const normalized = path.isAbsolute(p) |
| 201 | ? p |
| 202 | : p.startsWith("./") |
| 203 | ? p |
| 204 | : `./${p}`; |
| 205 | results.push(runner.require(outputDirectory, normalized)); |
| 206 | } |
| 207 | |
| 208 | if (!found) { |
| 209 | found = true; |
| 210 | filesCount++; |
| 211 | } |
no test coverage detected