question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:30
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
maxailloudcommented, Dec 6, 2022

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

7reactions
joshkelcommented, Dec 15, 2022

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
By default, Jest runs all tests and produces all errors into the console upon completion. ... The directory where Jest should output its...
Read more >
ReSharper - Configure code inspection settings - JetBrains
Select ReSharper | Options from the main menu or press Alt+R O , then choose Code Inspection | Settings on the left.
Read more >
Troubleshooting Code Coverage - Visual Studio (Windows)
See if there are any warnings or errors logged. Explanation—Code coverage analysis is done while tests are running.
Read more >
What type of errors could my code still contain even if I have ...
Any kind of ordinary logic bug, I guess? Memory corruption, buffer overrun, plain old wrong code, assignment-instead-of-test, the list goes on. Coverage is...
Read more >
Validation | Kiali
A description and complete list of Kiali validations. ... source: namespaces: - default - non-existing # warning - unexisting # warning to: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found