Cannot read property 'coverageData' of null when trying to generate code coverage
See original GitHub issueš Bug Report
See reproduction repo for better understanding
When trying to generate a coverage with jest, the tests run as they should, but no coverage data is collected and thereās a āCannot read property ācoverageDataā of nullā error in the console. This is likely because jest right now canāt work with the unique folder structure that we have on our project (see the reproduction repo).
The folder where the package.json and node_modules are right next to the folder where all the source files are. When the file to test and the test itself is in the same folder as the node_modules the coverage data is collected perfectly, however when it is in the folder next to the folder with the node_modules, it display the error mentioned in the first paragraph.
Feel free to close this if itās not a bug with jest, but at this point I cannot think of anything else that could be wrong here (other than our legacy folder structure).
To Reproduce
Steps to reproduce the behavior:
-
checkout this repo
-
run the commands in the projectās README
-
see the console for the error message
Expected behavior
Expected the coverage data to be collected and put out to the console.
Link to repl or repo (highly encouraged)
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS 10.14.1
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 10.15.1 - ~/.nvm/versions/node/v10.15.1/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.7.0 - ~/.nvm/versions/node/v10.15.1/bin/npm
npmPackages:
jest: ^24.1.0 => 24.1.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:17
- Comments:9 (1 by maintainers)
@wfortin As a short term and quick solution, I rolled back to jest@23.6.0 and I am able to see coverage on all files and run tests as per normal. Once there is a fix, I will update Jest to v24. Note that if you do rollback, make sure to use
setupTestFrameworkScriptFile
(deprecated in v24) instead ofsetupFilesAfterEnv
for your jest setup file location. See https://github.com/facebook/jest/issues/7758#issuecomment-459052457Is there any workaround while we wait for an official fix for this?