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.

Cannot write coverage reports

See original GitHub issue

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.

  • jest-vue-preprocessor has no issues reporting coverage.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
anteriovieiracommented, Mar 23, 2018

@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

1reaction
anteriovieiracommented, Feb 20, 2018

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to Write Coverage Reports:Cannot read property 'loc' of ...
We are getting this error when trying to run a coverage report while jest --coverage --ci --coverageDirectory=output/coverage/jest is running in ...
Read more >
Cannot generate Jest coverage report - Stack Overflow
All my tests are passing, but the coverage report always comes back empty. Here's what my jest.config.js looks like:
Read more >
Not able to generate ".coverage" report while running code ...
I'm trying to run code coverage testing from command line using below commands: vstest.console.exe CoverTest.dll /EnableCodeCoverage ...
Read more >
typescript-coverage-report - npm
Node command tool to generate TypeScript coverage report. ... This package fills the gap of a missing type coverage reporting tool which is ......
Read more >
Find out how much code you're testing - Angular
Code coverage reports show you any parts of your code base that might not be properly tested by your unit tests. If you'd...
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