Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MichaelBorde opened this issue Nov 8, 2022 · 104 comments
Open

Comments

@MichaelBorde
Copy link

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
@diegohaz
Copy link

diegohaz commented Nov 8, 2022

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

@SimenB
Copy link
Member

SimenB commented Nov 8, 2022

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 😅

@SimenB
Copy link
Member

SimenB commented Nov 8, 2022

Preset fixed in https://github.com/facebook/jest/releases/tag/v29.3.1.

It's midnight here now, so I'll need to revisit tomorrow and verify what's the correct behaviour for the other fields. Even if it makes sense that a certain option is a project config and not global, we need to look at what the behaviour is first - that can only change in the next major. But if more fields are wrongly warned about, we should fix that.

@webark
Copy link

webark commented Nov 9, 2022

● 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.

@MichaelBorde
Copy link
Author

I can confirm this works for preset option.

@Angeart
Copy link

Angeart commented Nov 11, 2022

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

@jlowcs
Copy link

jlowcs commented Nov 15, 2022

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

@dmeents
Copy link

dmeents commented Nov 16, 2022

I am also seeing this with slightly different options:

● Validation Warning:

  Unknown option "reporters" with value ["default", "jest-junit"] 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 ["<rootDir>/src/**/*.{ts,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 "coverageDirectory" with value "<rootDir>/coverage/" was found.
  This is probably a typing mistake. Fixing it will remove this message.

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

@asos-dominicjomaa
Copy link

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

@drackp2m
Copy link

drackp2m commented Nov 16, 2022

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,
};

@AlexSapoznikov
Copy link

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

@alopix
Copy link

alopix commented Nov 24, 2022

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

@kristojorg
Copy link

same issue with projects collectCoverage and coverageDirectory

@webark
Copy link

webark commented Nov 24, 2022

I feel like it's something to do with this https://github.com/facebook/jest/blob/6e5b1d60a1214e792b5229993b5475445e9c1a6e/packages/jest-config/src/index.ts#L56 I'll have to stick a debugger on there when i get to a computer next.

@asos-dominicjomaa
Copy link

@webark any luck debugging this issue?

@mauris
Copy link

mauris commented Nov 30, 2022

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.

@wimbarelds
Copy link

getting the coverageDirectory and maxConcurrency warnings with 29.3.1

I do have this is a jest.config.js located inside of a project folder; and so according to @SimenB 's comment, that is incorrect.

However though I am getting this warning, coverage is being placed in the configured directory.

@arnoudius
Copy link

I'm also getting these warnings after upgarding to 29.3.1

@sampath3112
Copy link

sampath3112 commented Dec 6, 2022

● 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//!(.spec|.jest).{js,jsx,vue,ts,tsx}", "!//*.d.ts"] was found.
This is probably a typing mistake. Fixing it will remove this message.

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

Seeing the same issue even after upgrading jest to 29.3.1 and @types/jest to ^29.2.4
@SimenB Can you please Take a look at this issue :)

@saguilarolmo
Copy link

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?

@tscislo
Copy link

tscislo commented Dec 11, 2023

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

@gligorkot
Copy link

Yeah, I have this same issue with collectCoverage, following.

@mhornbacher
Copy link

Having this problem for reporters when using typescript its valid but the runner gives me the same issue.

@MeghanBomberger
Copy link

I'm getting the same error but for watchPlugins

@miguelci
Copy link

miguelci commented Feb 6, 2024

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

@nbolton
Copy link

nbolton commented Feb 8, 2024

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)

@korpiq-tiketti
Copy link

korpiq-tiketti commented Mar 8, 2024

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 :D

● 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

@byjokese
Copy link

byjokese commented Mar 20, 2024

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

@alexey-sh
Copy link

● 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?

@wesfc
Copy link

wesfc commented Apr 5, 2024

'● 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.

@bfricka
Copy link

bfricka commented May 10, 2024

I want to correct the idea that reporters should be a global-only field. This absolutely doesn't make sense, at least in terms of the options passed. For example, it seems obvious that we should be able to configure different output directories for each project:

{
  reporters: ['default', ['jest-junit', { outputDirectory: '/path/to/projectA/junit' }]]
}

@bfricka
Copy link

bfricka commented May 10, 2024

I also want to add that, the problem here is less about superfluous warnings, and more that some of these settings I've tried simply do not work at all. For example, the current version of Jest (29.7.0), allows you to have coverageDirectory defined, without throwing an error. However, it does not respect this field at all. You can add whatever coverage directory you want, but it'll always output to coverage.

Similarly, you can shut the reporters error up by adding reporters config to jest-config/build/ValidConfig.js -> initialProjectOptions, but this doesn't mean the reporters field is respected on a per-project basis. In fact, it's completely ignored.

I'll have to dig in and see how this might be implemented. If there's appetite for this and the maintainers would like to point me in the right direction, I'd appreciate it.

@Khaldor48
Copy link

+1

@cumt-robin

This comment was marked as spam.

@unadlib
Copy link

unadlib commented Jul 10, 2024

Same warning(Jest v29.7.0)

Is there any further updates?

@AbhijeetDeyTR
Copy link

Facing the same warning in jest 29.7.0

@olegomon
Copy link

I'm having a validation warning on "testTimeout" with Jest 29.7.0

@woppa684
Copy link

woppa684 commented Jul 18, 2024

@SimenB Since Jest 29, about two years ago, many warnings about "unknown options" have been generated for no apparent reason. At some point someone made a PR that only fixed 1 or 2 of them but the others are still there (for example "reporters", that has been biting us for the last year).

These options still work on project level and they also make terribly good sense at project level! Why are these warnings generated? What was the idea behind it? And why is this not fixed when it was reported? It's a clear regression from v28, where it all worked as well, but there are no irrelevant warnings. In relation to your comment here: #13565 (comment), I imagine fixing it never happened?

Within our company it would really help to get rid of them to build up a bit of trust in Jest (over Karma, where we come from).

@ezintz
Copy link

ezintz commented Jul 23, 2024

@woppa684 I think the priority here is low, because Jest is showing warning but the options you set on project level are still working.

Within our company it would really help to get rid of them to build up a bit of trust in Jest (over Karma, where we come from).

From our experience Karma is worse. We have an Angular application and Karma is executing tests successfully even there are properties missing on an object (maybe just configuration? idk) - Jest fails which is good because you are sure the code is executed correctly and you have to fix your test cases correctly.

@artus9033
Copy link

Long story short: there's (afaik) no bug.

I also stumbled upon this problem and it seems like this issue should concentrate on updating the documentation & typings, since (as far as I inspected) the actual implementation at the moment works as it should.

This validation code in normalize.ts#L495 causes the warnings and stands in line with what @SimenB said in the first comments. Moreover, I tried and with jest 29.7.0, placing any coverage-related configuration props in a project config does not have any effect (apart from causing a validation warning, of course), while placing it in the global config works properly and does not cause any validation warnings.

I believe this issue should result in a change to the docs to point out that some properties (such as coverageReporters, coveragePathIgnorePatterns, etc.) are only allowed in global config and cannot be used in project config.

As one of the comments in this thread mentioned, jest does not provide separate exports for ProjectConfig and GlobalConfig, but such an improvement would be great for developer experience, since just annotating a config with the proper specialized type would protect devs from using props that are not allowed in the given config type.

CC: @MichaelBorde @SimenB

@sebastianhaberey
Copy link

So... after two years and 100 comments the answer is RTFM?

@artus9033
Copy link

This is what I found. I'm not a maintainer so don't know in-depth how jest has been built, but what I browsed in jest's code would stand in line with what I think (the separate validation code for project config I mentioned in my comment above). Also:

  • the first two comments in this thread, state a similar thing to what I found out, and mention specialized types in @jest/types that point ot the right direction (so actually a maintainer pointed out pretty much what I found, but in a less straightforward way, at the very beginning)
  • some options had literally no effect apart from throwing the warning when placed in the project config, but worked when I moved them to the global config here and they work properly, so this would practically confirm that the validation code is there for a reason

@sebastianhaberey
Copy link

I think the general issue here is that people are using Jest in a monorepo environment and are getting warnings that make them feel unsure about their build.

Since monorepos are a popular context for a library like Jest, it would make sense to see if those warnings can be eliminated.

As I understand it, some of these warnings can simply be eliminated by correcting faulty configurations. But in other cases it's not so easy: coverageDirectory may only be valid in the global configuration, but a lot of developers need it in the project configuration. So it's no use saying "works as intended" when the intended design isn't sufficient. If I'm reading the comments correctly, this has been fixed though, so thank you for that!

I think the goal should be to make Jest configurable enough to use it in a variety of monorepo settings without getting warnings. From what I gather, it's nearly there, it sounds like one or two more options need to be implemented at project level. Or, even easier, the warning needs to be removed because they already work fine on project level!

@artus9033
Copy link

Indeed, I agree that there's space for improvement and definitely I would also like to see this option available in project config. Yet, this issue is labelled as a bug, so most likely, it should be edited to be an improvement or alike.

@sebastianhaberey
Copy link

sebastianhaberey commented Aug 15, 2024

Yeah, the problem is that some options just worked in v28. Like coverageDirectory on project level. Then v29 came and suddenly there was a warning "coverageDirectory is not valid on project level" even though it did work on project level before. That's why many people feel this was a regression / bug in v29.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests