MCPcopy
hub / github.com/jestjs/jest / ensureNoDuplicateConfigs

Function ensureNoDuplicateConfigs

packages/jest-config/src/index.ts:268–302  ·  view source on GitHub ↗
(
  parsedConfigs: Array<ReadConfig>,
  projects: Config.GlobalConfig['projects'],
)

Source from the content-addressed store, hash-verified

266});
267
268const ensureNoDuplicateConfigs = (
269 parsedConfigs: Array<ReadConfig>,
270 projects: Config.GlobalConfig['projects'],
271) => {
272 if (projects.length <= 1) {
273 return;
274 }
275
276 const configPathMap = new Map();
277
278 for (const config of parsedConfigs) {
279 const {configPath} = config;
280
281 if (configPathMap.has(configPath)) {
282 const message = `Whoops! Two projects resolved to the same config path: ${chalk.bold(
283 String(configPath),
284 )}:
285
286 Project 1: ${chalk.bold(projects[parsedConfigs.indexOf(config)])}
287 Project 2: ${chalk.bold(
288 projects[parsedConfigs.indexOf(configPathMap.get(configPath))],
289 )}
290
291This usually means that your ${chalk.bold(
292 '"projects"',
293 )} config includes a directory that doesn't have any configuration recognizable by Jest. Please fix it.
294`;
295
296 throw new Error(message);
297 }
298 if (configPath !== null) {
299 configPathMap.set(configPath, config);
300 }
301 }
302};
303
304export interface ReadJestConfigOptions {
305 /**

Callers 1

readConfigsFunction · 0.85

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected