karma-runner / karma-runner/karma-coverage

TypeError: Cannot read property 'text' of undefined

Open
#341 7 comments 5 reactions 0 assignees View on GitHub
needs: feedback-from-author
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

not entirely sure if this is an issue with istanbul directly or karma-coverage, but i think it's an istanbul thing so i created [this issue](https://github.com/gotwarlost/istanbul/issues/846) with them but you may want to look into it too:

```js
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 you can reproduce it; just let me know what you need that i can provide and i'll provide it.

Contributor guide

Open the contributing guide

Research direction

Start with the stack trace in istanbul/lib/report/html.js, especially annotateBranches at line 288, and inspect how structuredText and startLine are used there. Reproduce the failure with karma-coverage if possible; done means the coverage report no longer throws when structuredText[startLine] is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.