Friday, November 09, 2018

Fix: TypeError: Cannot read property 'text' of undefined (while using karma-coverage-istanbul-reporter package in angular)

I was getting an below error while running the code coverage in angular project using karma-coverage and karma-coverage-istanbul-reporter packages.


ERROR:

TypeError: Cannot read property 'text' of undefined
    at {ApplicationPath}\node_modules\istanbul\lib\report\html.js:210:46


FIX:

Add below condition to existing if condition at the lines of 205, 236, 283 (node_modules\istanbul\lib\report\html.js)


&& structuredText[startLine] && structuredText[startLine].text



Line 205:
if (type === 'no' && structuredText[startLine] && structuredText[startLine].text) {

Line 236:
if (type === 'no' && structuredText[startLine] && structuredText[startLine].text) {

Line 283:
if (count === 0 && structuredText[startLine] && structuredText[startLine].text) {



No comments: