Skip to content

Commit

Permalink
added protection around structuredText calls
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Sep 24, 2015
1 parent 5e87c9c commit 4a5e92c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/report/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function annotateStatements(fileCoverage, structuredText) {
closeSpan = lt + '/span' + gt,
text;

if (type === 'no') {
if (type === 'no' && structuredText[startLine]) {
if (endLine !== startLine) {
endLine = startLine;
endCol = structuredText[startLine].text.originalLength();
Expand Down Expand Up @@ -228,7 +228,7 @@ function annotateFunctions(fileCoverage, structuredText) {
closeSpan = lt + '/span' + gt,
text;

if (type === 'no') {
if (type === 'no' && structuredText[startLine]) {
if (endLine !== startLine) {
endLine = startLine;
endCol = structuredText[startLine].text.originalLength();
Expand Down Expand Up @@ -275,7 +275,7 @@ function annotateBranches(fileCoverage, structuredText) {
openSpan = lt + 'span class="branch-' + i + ' ' + (meta.skip ? 'cbranch-skip' : 'cbranch-no') + '"' + title('branch not covered') + gt;
closeSpan = lt + '/span' + gt;

if (count === 0) { //skip branches taken
if (count === 0 && structuredText[startLine]) { //skip branches taken
if (endLine !== startLine) {
endLine = startLine;
endCol = structuredText[startLine].text.originalLength();
Expand Down

4 comments on commit 4a5e92c

@Xesenix
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wasn't this fix merged?
Im getting:

ERROR [coverage]: TypeError: Cannot read property 'text' of undefined
    at \node_modules\istanbul\lib\report\html.js:288:53

And when I add exactly same fix everything works for me.

@sander-vink
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What @Xesenix said, same issue here (and solved by applying this fix)!

@Millzor2890
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed my issue as well. Is there any reason it shouldnt be merged?

@motin
Copy link

@motin motin commented on 4a5e92c May 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three unmerged PRs (at least) include this fix:
This was already proposed to be fixed in
#816
#819
#881

Please sign in to comment.