gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 786 forks source link

TypeError: Cannot read property 'text' of undefined #846

Open andrewl-telnyx opened 6 years ago

andrewl-telnyx commented 6 years ago

not entirely sure if this is an issue with istanbul directly or karma-coverage, but i think it's an istanbul thing:

04 10 2017 09:34:48.018:ERROR [coverage]: TypeError: Cannot read property 'text' of undefined
    at project/node_modules/istanbul/lib/report/html.js:288:53
    at Array.forEach (native)
    at annotateBranches (project/node_modules/istanbul/lib/report/html.js:255:30)
    at HtmlReport.writeDetailPage (project/node_modules/istanbul/lib/report/html.js:426:9)
    at project/node_modules/istanbul/lib/report/html.js:489:26
    at SyncFileWriter.writeFile (project/node_modules/istanbul/lib/util/file-writer.js:57:9)
    at FileWriter.writeFile (project/node_modules/istanbul/lib/util/file-writer.js:147:23)
    at project/node_modules/istanbul/lib/report/html.js:488:24
    at Array.forEach (native)
    at HtmlReport.writeFiles (project/node_modules/istanbul/lib/report/html.js:482:23)
    at project/node_modules/istanbul/lib/report/html.js:484:22
    at Array.forEach (native)
    at HtmlReport.writeFiles (project/node_modules/istanbul/lib/report/html.js:482:23)
    at HtmlReport.writeReport (project/node_modules/istanbul/lib/report/html.js:566:14)
    at writeReport (project/node_modules/karma-coverage/lib/reporter.js:68:16)
    at project/node_modules/karma-coverage/lib/reporter.js:296:11

the problem is:

text = structuredText[startLine].text;

i guess it assumes structuredText[startLine] is always going to be a thing, and apparently at least once it is not a thing? I don't know how i can reproduce it but it appears every time we run karma with the coverage reporter. I created this issue with them. let me know what else i can provide to help y'all see the problem

Xesenix commented 6 years ago

I see they have separate branch that fixes this problem: https://github.com/gotwarlost/istanbul/commit/4a5e92c1261bd08ce5118d01c8a05ae54fc7458b Pretty old but not merged for some reason?

ffesseler commented 6 years ago

There are 2 PR opened that fix the issue but this project doesn't seem to be maintained anymore.

Xesenix commented 6 years ago

I have forked it and linking fork in my projects:

https://github.com/Xesenix/istanbul

and in projects:

npm i -D github:Xesenix/istanbul
benedictchen commented 6 years ago

@gotwarlost