| 532 | } |
| 533 | |
| 534 | export default async function normalize( |
| 535 | initialOptions: Config.InitialOptions, |
| 536 | argv: Config.Argv, |
| 537 | configPath?: string | null, |
| 538 | projectIndex = Number.POSITIVE_INFINITY, |
| 539 | isProjectOptions?: boolean, |
| 540 | ): Promise<{ |
| 541 | hasDeprecationWarnings: boolean; |
| 542 | options: AllOptions; |
| 543 | }> { |
| 544 | const {hasDeprecationWarnings} = validate(initialOptions, { |
| 545 | comment: DOCUMENTATION_NOTE, |
| 546 | deprecatedConfig: DEPRECATED_CONFIG, |
| 547 | exampleConfig: isProjectOptions ? VALID_PROJECT_CONFIG : VALID_CONFIG, |
| 548 | recursiveDenylist: [ |
| 549 | // 'coverageThreshold' allows to use 'global' and glob strings on the same |
| 550 | // level, there's currently no way we can deal with such config |
| 551 | 'coverageThreshold', |
| 552 | 'globals', |
| 553 | 'moduleNameMapper', |
| 554 | 'testEnvironmentOptions', |
| 555 | 'transform', |
| 556 | ], |
| 557 | ...(isProjectOptions && {unknown: unknownProjectOption}), |
| 558 | }); |
| 559 | |
| 560 | let options = normalizeMissingOptions( |
| 561 | normalizeRootDir(setFromArgv(initialOptions, argv)), |
| 562 | configPath, |
| 563 | projectIndex, |
| 564 | ); |
| 565 | |
| 566 | if (options.preset) { |
| 567 | options = await setupPreset(options, options.preset); |
| 568 | } |
| 569 | |
| 570 | if (!options.setupFilesAfterEnv) { |
| 571 | options.setupFilesAfterEnv = []; |
| 572 | } |
| 573 | |
| 574 | options.testEnvironment = resolveTestEnvironment({ |
| 575 | requireResolveFunction: requireResolve, |
| 576 | rootDir: options.rootDir, |
| 577 | testEnvironment: |
| 578 | options.testEnvironment || |
| 579 | require.resolve(DEFAULT_CONFIG.testEnvironment), |
| 580 | }); |
| 581 | |
| 582 | if (!options.roots) { |
| 583 | options.roots = [options.rootDir]; |
| 584 | } |
| 585 | |
| 586 | if ( |
| 587 | !options.testRunner || |
| 588 | options.testRunner === 'circus' || |
| 589 | options.testRunner === 'jest-circus' || |
| 590 | options.testRunner === 'jest-circus/runner' |
| 591 | ) { |