Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'start' of undefined #123

Closed
damonsutherland opened this issue Dec 20, 2017 · 7 comments · Fixed by #456
Closed

TypeError: Cannot read property 'start' of undefined #123

damonsutherland opened this issue Dec 20, 2017 · 7 comments · Fixed by #456

Comments

@damonsutherland
Copy link

The following stack is presented in the html for the covered entity:

TypeError: Cannot read property 'start' of undefined
at /home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-reports/lib/html/annotator.js:82:33
at Array.forEach (native)
at annotateFunctions (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-reports/lib/html/annotator.js:78:26)
at Object.annotateSourceCode (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-reports/lib/html/annotator.js:189:9)
at HtmlReport.onDetail (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-reports/lib/html/index.js:217:39)
at Visitor.(anonymous function) [as onDetail] (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-lib-report/lib/tree.js:34:30)
at ReportNode.Node.visit (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-lib-report/lib/tree.js:123:17)
at /home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-lib-report/lib/tree.js:116:23
at Array.forEach (native)
at visitChildren (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-lib-report/lib/tree.js:115:32)
at ReportNode.Node.visit (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-lib-report/lib/tree.js:126:5)
at Tree.visit (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-lib-report/lib/tree.js:158:20)
at /home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-api/lib/reporter.js:84:18
at Array.forEach (native)
at Object.write (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/istanbul-api/lib/reporter.js:82:35)
at browsers.forEach.browser (/home/ARBFUND/dsutherland/develop/@cw/hateoas/node_modules/karma-coverage-istanbul-reporter/src/reporter.js:82:16)

hateoas.zip

@damonsutherland
Copy link
Author

Note: I get similar stacks when generating other reports, i.e. lcovonly.

@gkemp94
Copy link

gkemp94 commented Aug 27, 2018

@damonsutherland Did you ever manage to get to the root of this issue? I'm experiencing the same issue.

Thanks.

@loftyduck
Copy link

Looks like the same issue as #39

@bennycode
Copy link

I am also hitting the "Cannot read property 'start' of undefined" error but only when I try to combine reports from two sources.

I have a coverage-browser.json file (created by Karma "lcov" reporter when running tests in a browser environment) and a coverage-final.json. I then merge both of them into a single HTML report using nyc report but when I view the HTML report I get the following error for most of the pages:

Cannot read property 'start' of undefined
TypeError: Cannot read property 'start' of undefined
at D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-reports\lib\html\annotator.js:92:34
at Array.forEach ()
at annotateFunctions (D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-reports\lib\html\annotator.js:88:26)
at Object.annotateSourceCode (D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-reports\lib\html\annotator.js:239:9)
at HtmlReport.onDetail (D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-reports\lib\html\index.js:269:23)
at Visitor.(anonymous function) [as onDetail] (D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:34:30)
at ReportNode.Node.visit (D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:121:17)
at D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:114:23
at Array.forEach ()
at visitChildren (D:\dev\projects\temp\karma-test\node_modules\nyc\node_modules\istanbul-lib-report\lib\tree.js:113:32)

Test repository:

@LunaPg
Copy link

LunaPg commented May 8, 2019

It's been a year since this issue is open, and I am experiencing this issue with typescript.
I'm not using rewire and I'm working on WSL.

Cannot read property 'start' of undefined
TypeError: Cannot read property 'start' of undefined
    at Object.keys.forEach.stName (/project/node_modules/istanbul-reports/lib/html/annotator.js:53:31)

@LunaPg
Copy link

LunaPg commented May 8, 2019

I've found a super weird manipulation to fix the problem !
But I don't have any idea why is works !

  1. Generate file
  2. Look at the html file : You 'll have the Cannot rest property error written is covered file
  3. Open /.nyc_outpu/processinfo/index
  4. generate once more your coverge
  5. You have another error on the console
Error: ENOTEMPTY: directory not empty, rmdir '/project/packages/diffusion-core/.nyc_output'     at Object.rmdirSync (fs.js:680:3)            
  1. Open the html file, this time it works fine

So maybe the .nyc_output file are not properly written, closed or have a problem on permission.

@godu
Copy link

godu commented Jun 5, 2019

istanbuljs/nyc#1124 (comment)

coreyfarrell added a commit that referenced this issue Aug 2, 2019
Frequently users run `nyc --all` in a way that causes source files to be
transpiled for actual testing but not transpiled for `--all`.  This
produces incompatible coverage data and inconsistantly wrong reporting.

The work around here is to drop coverage produced by `--all` for any
file where we have coverage produced by actual test runs.  This ensures
that we prefer code that was transpiled in the way which tests actually
ran.

Fixes #123, #224, #260, #322, #413
vivek-freshworks pushed a commit to freshworks/istanbuljs that referenced this issue Oct 26, 2023
Frequently users run `nyc --all` in a way that causes source files to be
transpiled for actual testing but not transpiled for `--all`.  This
produces incompatible coverage data and inconsistantly wrong reporting.

The work around here is to drop coverage produced by `--all` for any
file where we have coverage produced by actual test runs.  This ensures
that we prefer code that was transpiled in the way which tests actually
ran.

Fixes istanbuljs#123, istanbuljs#224, istanbuljs#260, istanbuljs#322, istanbuljs#413
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants