Support Jest's coverage options
See original GitHub issueI was surprised when I got a warning from npm test
stating that Jest’s coverage options aren’t supported. As a prior Jest user I expected them to be supported since Jest’s --coverage
option works fine.
While I know I could just change my test
script or eject, I think it would reduce confusion to support this out of the box. Is seems like there’s a whitelist for options, how easy would it be to implement support for all the coverage*
options?
Output
> react-scripts test --env=jsdom
Out of the box, Create React App only supports overriding these Jest options:
• collectCoverageFrom
• coverageReporters
• coverageThreshold
• snapshotSerializers.
These options in your package.json Jest configuration are not currently supported by Create React App:
• collectCoverage
• coveragePathIgnorePatterns
If you wish to override other Jest options, you need to eject from the default setup. You can do so by running npm ru
n eject but remember that this is a one-way operation. You may also file an issue with Create React App to discuss su
pporting more options out of the box.
npm ERR! Test failed. See above for more details.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Jest CLI Options
The jest command line runner has a number of useful options. You can run jest --help to view all available options. Many of...
Read more >Configuring code coverage in Jest, the right way
If you're using Jest, here are three options that should always be present in your Jest configuration: collectCoverage; collectCoverageFrom ...
Read more >Jest: support Coverage option : WEB-25778 - YouTrack
Jest provides Coverage when option --coverage is applied (https://facebook.github.io/jest/docs/cli.html#coverage). You can see output table in the console.
Read more >Configuring Code Coverage for TypeScript Files in Jest
In this lesson I demonstrate using the collectCoverageFrom configuration option to improve jest's coverage support for TypeScript files and ...
Read more >How to get the code coverage report using Jest?
After you write the tests, run the command npm run jest-coverage . This will create a coverage folder in the root directory. /coverage/icov- ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think you need to put
collectCoverage
intopackage.json
. Just runnpm test -- --coverage
as described here to get the coverage report.I am also not sure why you need
coveragePathIgnorePatterns
. Isn’tcollectCoverageFrom
enough to specify where you want it to be collected?Whoops, I just double checked and
react-scripts test --coverage
actually doesn’t run the watcher, it just runs tests once with coverage as if you ranjest --coverage
. My mistake, I’m not sure if that functionality is intentional though.