MCPcopy Create free account
hub / github.com/nodejs/undici / buildTestEnvironments

Function buildTestEnvironments

test/cache-interceptor/cache-tests.mjs:248–278  ·  view source on GitHub ↗

* @param {number} idx * @param {TestEnvironment[][]} testOptions * @returns {TestEnvironment[]}

(idx, testOptions)

Source from the content-addressed store, hash-verified

246 * @returns {TestEnvironment[]}
247 */
248function buildTestEnvironments (idx, testOptions) {
249 let baseEnvironments = testOptions[idx]
250
251 if (idx === 0) {
252 // We're at the beginning
253 baseEnvironments = baseEnvironments.map(
254 environment => joinEnvironments(BASE_TEST_ENVIRONMENT, environment))
255 }
256
257 if (idx + 1 >= testOptions.length) {
258 // We're at the end, nothing more to make a matrix out of
259 return baseEnvironments
260 }
261
262 /**
263 * @type {TestEnvironment[]}
264 */
265 const environments = []
266
267 // Get all of the environments below us
268 const subEnvironments = buildTestEnvironments(idx + 1, testOptions)
269
270 for (const baseEnvironment of baseEnvironments) {
271 const combinedEnvironments = subEnvironments.map(
272 subEnvironment => joinEnvironments(baseEnvironment, subEnvironment))
273
274 environments.push(...combinedEnvironments)
275 }
276
277 return environments
278}
279
280/**
281 * @param {Array<() => Promise<WorkerResult>>} jobs

Callers 1

cache-tests.mjsFile · 0.85

Calls 3

joinEnvironmentsFunction · 0.85
mapMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected