Hi, I've recently attempted moving to vue-jest from jest-vue-preprocessor. However, it seems like there's an issue with the conversion of .vue files that's blocking the coverage reports.
Here's the stack trace:
Failed to write coverage reports:
ERROR: TypeError: Cannot read property 'decl' of undefined
STACK: TypeError: Cannot read property 'decl' of undefined
at path/node_modules/istanbul-reports/lib/lcovonly/index.js:32:38
at Array.forEach (<anonymous>)
at LcovOnlyReport.onDetail (path/node_modules/istanbul-reports/lib/lcovonly/index.js:30:28)
at LcovReport.(anonymous function) [as onDetail] (path/node_modules/istanbul-reports/lib/lcov/index.js:21:24)
at Visitor.(anonymous function) [as onDetail] (path/node_modules/istanbul-lib-report/lib/tree.js:34:30)
at ReportNode.Node.visit (path/node_modules/istanbul-lib-report/lib/tree.js:123:17)
at path/node_modules/istanbul-lib-report/lib/tree.js:116:23
at Array.forEach (<anonymous>)
at visitChildren (path/node_modules/istanbul-lib-report/lib/tree.js:115:32)
at ReportNode.Node.visit (path/node_modules/istanbul-lib-report/lib/tree.js:126:5)
The reason I'm filing this here is because I have no such issues if I use jest-vue-preprocessor instead. Digging through the istanbul code gives me
var fc = node.getFileCoverage()
console.log(fc)
FileCoverage {
data:
{ path: 'unknown',
statementMap:
{ '0': [Object],
'1': [Object],
'2': [Object],
'3': [Object],
'4': [Object],
'5': [Object],
'6': [Object] },
fnMap: {},
branchMap: {},
s:
{ '0': 18,
'1': 20,
'2': 18,
'3': 20,
'4': 15,
'5': 13,
'6': 15,
'7': NaN,
'8': NaN,
'9': NaN,
'10': NaN,
'11': NaN,
'12': NaN,
'13': NaN,
'14': NaN,
'15': NaN,
'16': NaN,
'17': NaN,
'18': NaN,
'19': NaN,
'20': NaN,
'21': NaN,
'22': NaN,
'23': NaN,
'24': NaN,
'25': NaN,
'26': NaN,
'27': NaN },
f:
{ '0': NaN,
'1': NaN,
'2': NaN,
'3': NaN,
'4': NaN,
'5': NaN,
'6': NaN,
'7': NaN,
'8': NaN,
'9': NaN,
'10': NaN,
'11': NaN },
b:
{ '0': [Array],
'1': [Array],
'2': [Array],
'3': [Array],
'4': [Array],
'5': [Array],
'6': [Array],
'7': [Array],
'8': [Array],
'9': [Array],
'10': [Array],
'11': [Array],
'12': [Array],
'13': [Array] },
_coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c',
hash: 'd3767ca38b776b618c16aa6dc3fa8c1632bfc5e2' } }
Looks to me like the fnMap object is strangely missing. If I mess with the source code to avoid throwing errors, none of my .vue files have coverage reports on them.
Thanks for the bug report.
Can you post a link to the repo where you're having this problem? I'm unable to reproduce with the info you've given.
Hey! Thanks for the quick turnaround. Unfortunately I couldn't find the root cause and the repo is for a private project. (Also now vue-cli comes with Jest as an option which should rescue everyone who runs into this in the future).
If anyone happens to stumble upon the same issue, these are the changes I made to my setup.
rootDir: path.resolve(__dirname, './'), to my jest configtransform-es2015-modules-commonjs and dynamic-import-node to the test env of my .babelrc.Can you try with vue-jest 1.3.0?
Previously we were adding a sourcemap as a comment, now we're returning it as part of the output.
@eddyerburgh I'm using version v2.0.0 and the same error happened to me.
Failed to write coverage reports:
ERROR: TypeError: Cannot read property 'decl' of undefined
STACK: TypeError: Cannot read property 'decl' of undefined
at /home/circleci/repo/node_modules/istanbul-reports/lib/lcovonly/index.js:32:38
at Array.forEach (<anonymous>)
...
report: https://circleci.com/gh/buefy/buefy/23 -> section Run tests
The same problem.
@TheDeveloperTom I able to solve, I simply removed the istanbul plugin.
Make sure you are not using the babel-plugin-istanbul plugin. Jest wraps Istanbul, and therefore also tells Istanbul what files to instrument with coverage collection
seeing the same issue
Most helpful comment
@TheDeveloperTom I able to solve, I simply removed the istanbul plugin.