jest: [Bug]: Validation warnings for options like preset or coverage directory

Version

29.3.0

Steps to reproduce

Use a jest.config.ts like:

export default {
  preset: './jest.preset.js',
  coverageDirectory: './coverage',
};

Expected behavior

Run tests using ./node_modules/.bin/jest without any warnings.

Actual behavior

● Validation Warning:

  Unknown option "preset" with value "./jest.preset.js" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "coverageDirectory" with value "./coverage" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

Additional context

Might be related to the missing default option for preset or coverage in packages/jest-config/src/ValidConfig.ts.

Environment

System:
    OS: macOS 13.0
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 16.18.0 - ~/.volta/tools/image/node/16.18.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.19.2 - ~/.volta/tools/image/node/16.18.0/bin/npm
  npmPackages:
    jest: ^29.3.0 => 29.3.0

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 153
  • Comments: 89 (9 by maintainers)

Commits related to this issue

Most upvoted comments

In Version 29.5.0, I get the warnings listed below under my nx repo. It’d be great if there were a configuration switch to turn off warnings that are unnecessary and for which the code performs the correct operation.

● Validation Warning:

  Unknown option "coverageDirectory" with value "../../coverage/apps/wrap-state" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverage" with value true was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["./src/lib/**"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

jest.preset.js…

const nxPreset = require("@nx/jest/preset").default;

const globalConf = {
  collectCoverage: true,
  coverageDirectory: `${process.env.NX_WORKSPACE_ROOT}/coverage/${process.env["NX_TASK_TARGET_PROJECT"]}`,
};

module.exports = { ...nxPreset, ...globalConf };

Would it make sense to document project vs global config and then adjust the warning? API documentation currently does not specify which configs are global, project or both.

We managed to fix most of these warning by consolidating settings in jest.preset.js in the base of our monorepo.

However, we want to specify the coverage directory for each project in that monorepo to be under the coverage directory of the root of the monorepo while maintaining separate reports for each project. This simplifies scanning and production of summary reports.

Thus, we need to specify a unique coverageDirectory in the jest.config.ts file of each project. This works fine, it is just annoying that we get a Validation Warning for each project. Since this is the only want to get a consolidated directory containing all the coverage reports, this setting needs to be supported in each jest.config.ts without generating a validation warning.

If I understand this issue correctly:

  • The warnings indicate that per-project Jest configs (i.e., files referenced by a Jest config projects entry) are using configuration settings like coverageDirectory, coverageReporters, and collectCoverageFrom that can only apply at the global level.
  • This feature (warning about per-project settings that have no effect because they can only apply at the global level) was added in #13565.
  • The “correct” fix is to adjust your Jest configs - any project config file (i.e., anything that’s referenced by another Jest config’s projects) shouldn’t have these settings.

Am I understanding correctly?

In my opinion, it’s sometimes useful to be able to use global settings in project configs - maybe you want to reuse a single configuration object for both, or maybe you want each package in a monorepo to have a jest.config.ts so that Jest can be run at the monorepo level or per project and share the same configs. (NX, for example, defaults to putting global settings in per-project configs, for whatever reason.) Maybe Jest shouldn’t warn on this, or should only warn if --debug or --showConfig is given, or should wait until Jest 30 and make a concrete recommendation about stricter separation of global and project settings then?

@SimenB any updates on this?

I’m getting same error on >29.3

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["<rootDir>/components/**/*.vue", "<rootDir>/pages/**/*.vue"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

It works if you downgrade to 28.1.3…enjoy

Hello. I do have the same issue with the coverageDirectory and coverageReporters options. I am using the 29.3.1 version.

I upgraded to jest@29.6.2 but I still see warnings for “collectCoverage” and “coverageReporters”:

● Validation Warning:
  Unknown option "collectCoverage" with value true was found.
  This is probably a typing mistake. Fixing it will remove this message.
  Configuration Documentation:
  https://jestjs.io/docs/configuration
● Validation Warning:
  Unknown option "coverageReporters" with value ["text", "cobertura", "lcov"] was found.
  This is probably a typing mistake. Fixing it will remove this message.
  Configuration Documentation:
  https://jestjs.io/docs/configuration

I’m seeing these on my end:

● Validation Warning:

  Unknown option "coverageReporters" with value ["lcovonly", "html", "json-summary", "json", "text"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "watchPlugins" with value ["jest-watch-master"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "projects" with value ["."] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

I started using this patch for coverageDirectory so that our Nx monorepo would stop throwing warnings. If using coverageDirectory at a project level is truly not intended can we get some sort of migration path?

diff --git a/build/ValidConfig.js b/build/ValidConfig.js
index 889ea1e5e802fdf9e3d83a2213bdee91fbd724f7..08157a5cfefb5637c3b961d5ad6b1b7c05ed2a87 100644
--- a/build/ValidConfig.js
+++ b/build/ValidConfig.js
@@ -226,6 +226,7 @@ const initialProjectOptions = {
   cache: true,
   cacheDirectory: '/tmp/user/jest',
   clearMocks: false,
+  coverageDirectory: 'coverage',
   coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
   dependencyExtractor: '<rootDir>/dependencyExtractor.js',
   detectLeaks: false,

Sorry about that! I’m fixing preset in #13583 as that’s obviously a bug. However, e.g. testTimeout only works as global config, not as part of projects.

https://github.com/facebook/jest/blob/dfc87111e708b9294dc54ab0c17712972d042c1c/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts#L61-L63 https://github.com/facebook/jest/blob/dfc87111e708b9294dc54ab0c17712972d042c1c/packages/jest-jasmine2/src/index.ts#L43

It probably should be project config, but it’s not. same with coverageDirectory and collectCoverageFrom at least. Not sure about reporters - that is probably correct as global.


TBH global vs project config is confusing even to me after 5 years of contributing and maintaining Jest 😅

Also seeing similar to the above for supposedly valid options:

● Validation Warning:

  Unknown option "verbose" with value true was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "jest-teamcity-reporter"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "projects" with value ["<rootDir>/src/jest.*.config.js"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "name" with value "jsdom" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

jest@29.5.0, is there any solution?

Hi there,

I’m currently encountering a warning message in Jest that I’m having trouble resolving. The message reads:

Validation Warning:

Unknown option "coverageDirectory" with value "../../coverage/apps/epsite" was found.
This is probably a typing mistake. Fixing it will remove this message.

Configuration Documentation:
https://jestjs.io/docs/configuration

I have checked my Jest configuration file and confirmed that the “coverageDirectory” option is spelled correctly and is a valid Jest configuration option. I’m running the latest version of Jest, and I don’t believe I’m using any third-party libraries or presets that could be causing this issue.

I’m hoping someone in the community can help me figure out what’s causing this warning message and how I can resolve it. Any advice or suggestions would be greatly appreciated.

Thank you!

● Validation Warning:

  Unknown option "coverageProvider" with value "v8" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["**/*.{ts,tsx}", "!**/*.d.ts", "!{index,routes}.ts"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

I’m still getting some warnings like this post jest-config 29.3. Forcing it to <29.3 removes the validation messages.

Seems to be fixed in 29.6.1 🎉

nope, still happening

CleanShot 2023-07-17 at 12 56 11@2x

However, we want to specify the coverage directory for each project in that monorepo to be under the coverage directory of the root of the monorepo while maintaining separate reports for each project. This simplifies scanning and production of summary reports.

Another +1 to this, same setup here. So far coverageDirectory is the only configuration option causing this warning for us. Would like to see continued support for this property on a project level.

Seeing the same issue with: coverageReporters, coverageProvider, verbose and watchPlugins.

I’m experiencing the same issue with coverageDirectory and reporters in a mono repo managed by nx , while trying to use the jest-stare plugin. ./packages/constants/jest.config.ts

export default {
    coverageDirectory: '../../docs/reports/packages/constants',
    reporters: [
        'default',
        [
            'jest-stare',
            {
                coverageLink: './coverage.html',
                resultDir: 'docs/reports/packages/constants',
                resultHtml: 'test-report.html',
                reportTitle: 'Constants Report',
                reportHeadline: 'Constants Report',
                reportSummary: 'Tests report for the constants package'
            }
        ]
    ],
    displayName: 'constants'
}

I threw in a console.trace just before the warning to get some context

Trace: JEST-VALIDATE
    at Object.get [as validate] (PATH_TO_MY_REPO/node_modules/@jest/core/node_modules/jest-validate/build/index.js:39:13)
    at normalize (PATH_TO_MY_REPO/node_modules/@jest/core/node_modules/jest-config/build/normalize.js:553:55)
    at readConfig (PATH_TO_MY_REPO/node_modules/@jest/core/node_modules/jest-config/build/index.js:181:74)
    at async Promise.all (index 0)
    at async readConfigs (PATH_TO_MY_REPO/node_modules/@jest/core/node_modules/jest-config/build/index.js:463:27)
    at async runCLI (PATH_TO_MY_REPO/node_modules/@jest/core/build/cli/index.js:152:59)

From what I can tell, when I’m running nx run test to execute jest tests, it starts the jest cli and passes it the config options from my PATH_TO_MY_REPO/packages/constants/project.json and PATH_TO_MY_REPO/packages/constants/jest.config.ts. The jest cli then passes it through jest-config, where it defines an example config to validate against, using jest-validate. It chooses the example for a project, which is missing those config options.

jest-validate has a README.md, and accepts a json object to configure it’s behavior. jest-config does not appear to have a README.md, and does not seem to have an ability to pass on options to jest-validate.

In my opinion, initialOptions and initialProjectOptions should not differ. It adds unnecessary/undocumented complexity when trying to determine why a config option isn’t working.

It also hamstrings plugins from being able to use their own config if jest is going to say their options are invalid.

Same mistakes here with jest 29.3.1 and ts-jest 29.0.3:

● Validation Warning:

  Unknown option "coverageDirectory" with value "../../coverage/apps/api" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "coverageReporters" with value ["html", ["text-summary"]] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

Problems are solved downgrading to jest 28.1.3 and ts-jest 28.0.8.

My configuration is:

export default {
  displayName: 'api',
  preset: '../../jest.preset.js',
  testEnvironment: 'node',
  maxWorkers: 2,
  transform: {
    '^.+\\.[tj]s$': [
      'ts-jest',
      {
        tsconfig: '<rootDir>/tsconfig.spec.json',
        diagnostics: {
          ignoreCodes: ['TS151001'],
        },
      },
    ],
  },
  moduleFileExtensions: ['ts', 'js'],
  coverageDirectory: '../../coverage/apps/api',
  coverageReporters: ['html', ['text-summary', { skipFull: true }]],
  clearMocks: true,
};

I updated to “ts-jest”: “~29.1.1”, “jest”: “~29.7.0” and this still occurs

● Validation Warning:

Unknown option “coverageReporters” with value [“lcov”, “text-summary”] was found. This is probably a typing mistake. Fixing it will remove this message.

Configuration Documentation: https://jestjs.io/docs/configuration

● Validation Warning:

Unknown option “collectCoverage” with value true was found. This is probably a typing mistake. Fixing it will remove this message.

Configuration Documentation: https://jestjs.io/docs/configuration

● Validation Warning:

Unknown option “maxConcurrency” with value 4 was found. This is probably a typing mistake. Fixing it will remove this message.

Configuration Documentation: https://jestjs.io/docs/configuration

● Validation Warning:

Unknown option “passWithNoTests” with value true was found. This is probably a typing mistake. Fixing it will remove this message.

Configuration Documentation: https://jestjs.io/docs/configuration

● Validation Warning:

Unknown option “reporters” with value [“default”, [“C:\workspace\rfq-ui-migration\rfq-ui-migration\node_modules\jest-html-reporter\dist\index.js”, {“includeFailureMsg”: true , “includeSuiteFailure”: true, “outputPath”: “reports/tests.html”, “pageTitle”: “Test Report”, “sort”: “default”, “theme”: “defaultTheme”}]] was found. This is probably a typing mistake. Fixing it will remove this message.

Configuration Documentation: https://jestjs.io/docs/configuration

Still getting this warning for the reporters option even after upgrading to version 29.6.1. Upgrading did fix it for coverageDirectory though.

We managed to fix most of these warning by consolidating settings in jest.preset.js in the base of our monorepo.

However, we want to specify the coverage directory for each project in that monorepo to be under the coverage directory of the root of the monorepo while maintaining separate reports for each project. This simplifies scanning and production of summary reports.

Same for reporters actually. We have config for jest-junit in there that also specifies a project-specific outputDirectory.

As you state, the functionality is obviously supported and works fine, the warning should be removed.

Getting same warnings with jest@29.3.1

Having same issues. Would like to ask what’s the state with it?

Not sure if this has already been mentioned, but this patch-package patch works for us…

patches/jest-validate+29.7.0.patch:

diff --git a/node_modules/jest-validate/build/warnings.js b/node_modules/jest-validate/build/warnings.js
index 1860d5a..aef7d81 100644
--- a/node_modules/jest-validate/build/warnings.js
+++ b/node_modules/jest-validate/build/warnings.js
@@ -23,6 +23,13 @@ function _interopRequireDefault(obj) {
  */
 
 const unknownOptionWarning = (config, exampleConfig, option, options, path) => {
+  // HACK: do not warn about coverageReporters and reporters.
+  // they are actually valid options, but are being reported as invalid.
+  // https://github.com/jestjs/jest/issues/14701
+  if (option === "coverageReporters" || option === "reporters") {
+    return;
+  }
   const didYouMean = (0, _utils.createDidYouMeanMessage)(
     option,
     Object.keys(exampleConfig)

I definitely don’t think this should be closed without some kind of resolution or direction.

However, we want to specify the coverage directory for each project in that monorepo to be under the coverage directory of the root of the monorepo while maintaining separate reports for each project. This simplifies scanning and production of summary reports.

Thus, we need to specify a unique coverageDirectory in the jest.config.ts file of each project.

This is exactly our situation.

Also, when generating components using standard Nx commands, the coverageDirectory setting in each project is the default behavior. So even if we removed all the coverageDirectory settings in all the existing Nx projects, every new project would introduce the warning again.

same issue with projects collectCoverage and coverageDirectory

This validation warning happens for me when I utilize a base Jest config in a monorepo project and utilize that base config in sub-package config files;

root/
-- packages/
---- package1/
------ jest.config.ts
---- package2/
------ jest.config.ts
jest.config.base.ts
jest.config.ts
package.json

all jest.config.ts files are importing and extending the jest.config.base.ts file

import jestBaseConfig from "./jest.config.base";

const jestConfig: JestConfigWithTsJest = {
  ...jestBaseConfig,
  moduleNameMapper: {
    "^(\\.{1,2}/.*)\\.js$": "$1",
  },
 ...
}

many validation warnings

● Validation Warning:

  Unknown option "forceExit" with value true was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "silent" with value false was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

base config is

import type { JestConfigWithTsJest } from "ts-jest";

const jestBaseConfig: JestConfigWithTsJest = {
  preset: "ts-jest",
  testEnvironment: "node",
  detectOpenHandles: true,
  forceExit: true,
  silent: false,
  verbose: true,
  testPathIgnorePatterns: ["node_modules", "dist", "env"],
  moduleDirectories: ["node_modules"],
  extensionsToTreatAsEsm: [".ts"],
  transform: {
    "^.+\\.tsx?$": [
      "ts-jest",
      {
        //the content you'd placed at "global"
        useESM: true,
      },
    ],
  },
};

export default jestBaseConfig;

I ran into this same issue today. Very weird. Using 28.1.3 does seem to address the problem, but, I’d really prefer to be using 29.x.x. What’s happening on this issue?

I wonder if we should take the opportunity to go all in on generating a json schema and just use ajv or something (like eslint does) to validate?

Ref https://github.com/jestjs/jest/issues/11963

I haven’t done anything more since landing the basics: https://github.com/jestjs/jest/blob/main/packages/jest-schemas/src/index.ts

Okay, so SOME options appear to be fixed, the one I was using coverageDirectory is fixed.

Hi I am also seeing the similar issue while try to run : npx jest --coverage RelativePath image

I have following versions installed:

  • @nrwl/jest”: “16.2.2”,
  • “jest”: “^29.4.3”,
  • “jest-environment-jsdom”: “28.1.3”,
  • “jest-preset-angular”: “^13.1.1”,
  • “ts-jest”: “29.1.0”,
  • “tslib”: “^2.5.3”,

Can someone please help me here?

Still throwing errors, but the config itself works fine

● Validation Warning: Unknown option “collectCoverage” with value true was found. This is probably a typing mistake. Fixing it will remove this message. Configuration Documentation: https://jestjs.io/docs/configuration ● Validation Warning: Unknown option “coverageDirectory” with value “…/…/.cache/coverage/apps/hooks” was found. This is probably a typing mistake. Fixing it will remove this message. Configuration Documentation: https://jestjs.io/docs/configuration ● Validation Warning: Unknown option “collectCoverageFrom” with value [“src//*.{js,ts,jsx,tsx}", "!/index.(js|ts|jsx|tsx)”, “!**/types.(js|ts|jsx|tsx)”] was found. This is probably a typing mistake. Fixing it will remove this message. Configuration Documentation: https://jestjs.io/docs/configuration ● Validation Warning: Unknown option “coverageReporters” with value [“html”, “json”] was found. This is probably a typing mistake. Fixing it will remove this message. Configuration Documentation: https://jestjs.io/docs/configuration

I can confirm that this is an issue since 29.0.0 (not sure about the prereleases). Reverting back to the last version of v28 and the warning went away.

Some problem here. Also using NX v18.1.1 and jest v29.7.0.

Validation Warning:

  Unknown option "coverageReporters" with value ["cobertura", "html", "text-summary"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration


Validation Warning:

  Unknown option "reporters" with value XXXXXX was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

I am also using jest on a monorepo with turborepo and deployed in Vercel. With the verbose: true setting I get the same warning, but it seems to work. Well… work but in a strange way. Because the logs are marked in red even if the test passes XD. I’m using the version 29.7.0 of Jest I understand that this problem may be related to this warning. Do you know more about the solution in Jest version 29?

Coverage configuration warnings were removed for me 🎉. All of my remaining warnings are for watchPlugins

I had Unknown option "default" with value ... issue with my ESM ("type": "module") project.

This issue occurs due to the way jest checks if imported object is ES module

if (obj.__esModule) return obj:
else return { default: obj }

To fix t you have two options:

  • In case you’re a user of TypeScript and able to enable esModuleInterop option - do it.
  • In case you’re not able to do so, or you’re not using TS - add exported constant as follows.
    export const __esModule = true;
    export default cfg;
    

I got the same issue on jest@29.4.3

● Validation Warning:

  Unknown option "projects" with value ["<rootDir>/src"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

for the jest 29.7

It seems like the documentation contains wrong information about configuration Is it possible to fix it in 2024? How many years should be enough to fix it?

Same for collectCoverage while using

  • jest@29.7.0
  • ts-jest@29.1.2

● Validation Warning:

Unknown option “collectCoverage” with value true was found. This is probably a typing mistake. Fixing it will remove this message.

Configuration Documentation: https://jestjs.io/docs/configuration

I get those warnings with 29.6.2

● Validation Warning:

  Unknown option "collectCoverage" with value false was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "projects" with value ["<rootDir>/src"] was found.     
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "silent" with value true was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testSequencer" with value "./jest.sequencer.js" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration```

Thanks for the list! coverageReporters , maxConcurrency, reporters (probably verbose as well as AFAIK it’s only used in reporters) and watchPlugins at least are global config so the warning is correct for those. The others seem reasonable to me, will fix. But as mentioned in https://github.com/facebook/jest/issues/13576#issuecomment-1307946313 most really are global config and have no effect when specified as project config.

Also seeing those warnings with several options:

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "testTimeout" with value 5000 was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "reporters" with value ["default", "github-actions"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

● Validation Warning:

  Unknown option "collectCoverageFrom" with value ["packages/ariakit/src/**/*.{js,ts,tsx}", "packages/ariakit-utils/src/**/*.{js,ts,tsx}", "!**/__examples__/**", "!**/*test.{js,ts,tsx}", "!**/test-*.{js,ts}"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

'● Validation Warning ' Unknown option "reporters" with value ["default", ["<rootDir>/node_modules/jest-junit/index.js", {"classNameTemplate": "{classname}: {title}", "suiteName": "Unit tests (Jest)", "suiteNameTemplate": [Function suiteNameTemplate], "titleTemplate": "{classname}: {title}"}]] was found.' ' This is probably a typing mistake. Fixing it will remove this message. ' Configuration Documentation: 'https://jestjs.io/docs/configuration'

For the Jest 29.7.0

The error appears only when I run tests from the test explorer (vscode), when I run “npm t” there’s no error.

Funny how our monorepo projects get Unknown option "verbose" with value true followed by a helpful link to documentation where the examples consistently use option “verbose” with value true 😄

● Validation Warning:

  Unknown option "verbose" with value true was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

I had Unknown option "default" with value ... issue with my ESM ("type": "module") project. This issue occurs due to the way jest checks if imported object is ES module

if (obj.__esModule) return obj:
else return { default: obj }

So I have been looking at the same issue for the whole day now. I have a similar project that uses the exact same versions and configuration as the one that’s failing that DOES work normally and it’s really frustrating. For some reason, my jest.config.ts file is not interpreted as TypeScript then I guess. What could cause this?

Finally found what the difference was between the project that was failing and the one that was succeeding. Apparently the failing project ran jest via ts-node instead of directly (because of a custom SDK we built on top of Nx, while testing the SDK itself). Maybe it helps someone 😃

I’m facing the same issue. Is there any documentation about what is valid in project vs global config? I see that @jest/types exposes a ProjectConfig and GlobalConfig type but the jest package does not. Only InitialOptions from the Config namespace is exposed on the jest package. If i try and require the types from jest I get an error pushing me to use jest instead.

To further complicate this, the docs state

With the projects option enabled, Jest will copy the root-level configuration options to each individual child configuration during the test run, resolving its values in the child’s context. This means that string tokens like <rootDir> will point to the child’s root directory even if they are defined in the root-level configuration.

But in my testing I discovered:

  • some properties are only to be used on the GlobalConfig
    • e.g. reporters, testTimeout, coverageReporters
  • some properties are not copied to the project level config even if specified on the root config
    • e.g moduleFileExtensions, modulePathIgnorePatterns, snapshotFormat, testPathIgnorePatterns

I am discovering these by trial and error. It would be great to get some documentation about how root/project configs are merged and address the typing issues.

It is just right time to fix this. @SimenB is landing breaking changes and preparing Jest 30 release.

any updates on this?

same here, version: “jest”: “^29.5.0”, image

What I don’t understand here is why the projects config when listed in my top-level jest.config.ts is giving an error:

import type { Config } from "jest";

/**
 * This Jest config tells Jest about our workspaces (Jest calls them
 * projects). Each workspace will have it's own Jest config which
 * extends the one in packages/jest-presets.
 *
 */
const jestconfig: Config = {
  projects: ["./apps/*", "./packages/*"]
};

export default jestconfig;

The only addition I would tack on to what you’re saying is that: Despite the warning, the project setting does work correctly and actually does place coverage reports in the (per project) specified directory.