Bug with babel-jest when coverage mode is on
See original GitHub issueš Bug Report
Jest returns an error when babel ignore some directory and --coverage mode is enabled:
babel-jest: Babel ignores server/init/index.js - make sure to include the file in Jestās transformIgnorePatterns as well.
Adding this directory in transformIgnorePatterns - do not help.
When we disable coverage all is working properly.
To Reproduce
Steps to reproduce the behavior: OS: Windows 10 babel-jest: 24.7.1 jest: 24.6.0
.babelrc
{ ... "only": [ "client/", "test/" ] ... }
jest-config.js
{ ... "transform": { "^.+\\.jsx?$": "babel-jest" }, "transformIgnorePatterns": [ "/server/", "/node_modules/" ], ... }
command
jest test/ --coverage --verbose
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:5
Top Results From Across the Web
No code coverage in Babel Jest - Stack Overflow
Finally got answer. It was a bug in Babel. See how to fix this issue there : https://github.com/facebook/jest/issues/632.
Read more >babel ignores - make sure to include the file in jest's ... - You.com
Bug Report. Jest returns an error when babel ignore some directory and --coverage mode is enabled: babel-jest: Babel ignores server/init/index.js - makeĀ ...
Read more >CodeCoverage/Firefly - MozillaWiki
Coverage Data - Identify coverage gaps; Bugs Data - Identify the number ... fixed in the file to its coverage numbers in various...
Read more >flow-coverage-report - npm Package Health Analysis - Snyk
Learn more about flow-coverage-report: package health score, popularity, ... new --strict-coverage option to enforce a more strict coverage reporting mode.
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

Using
coveragePathIgnorePatternsisnāt an option if you want the coverage report to include all tests, not just those that were transformed.Thereās some kind of conflict between
transformandtransformIgnorePatternswhencoverageis used. @ni1son, the pattern"^.+\\.jsx?$"is very permissive and matches all js/x files it finds. I would expect that adding directories totransformIgnorePatternslike you have would be sufficient. It actually seems to work fine without the coverage flag, but I ran into the same problem when I wanted to use coverage.Workaround I found is to use a more specific pattern in
transformso that I donāt need to usetransformIgnorePatternsat all:config/jest.config.js
config/babel.config.js
You can ignore most of the details, the relevant part is the specification of
\\/src\\/in'\\/src\\/.+\\.[t|j]sx?$', since thatās the only directory I actually want transformed. The files and tests in config/ and in scripts/ are just run straight by Node.Try adding
coveragePathIgnorePatterns.source: https://github.com/facebook/jest/blob/master/docs/Configuration.md