istanbul
istanbul copied to clipboard
Cannot read property 'text' of undefined
In coverage reporter (html)
Trace:
TypeError: Cannot read property 'text' of undefined
at /Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:210:45
at Array.forEach (native)
at annotateStatements (/Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:193:33)
at HtmlReport.Report.mix.writeDetailPage (/Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:428:9)
at /Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:489:26
at SyncFileWriter.extend.writeFile (/Users/arusakov/myproject/node_modules/istanbul/lib/util/file-writer.js:57:9)
at FileWriter.extend.writeFile (/Users/arusakov/myproject/node_modules/istanbul/lib/util/file-writer.js:147:23)
at /Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:488:24
at Array.forEach (native)
at HtmlReport.Report.mix.writeFiles (/Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:482:23)
at /Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:484:22
at Array.forEach (native)
at HtmlReport.Report.mix.writeFiles (/Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:482:23)
at HtmlReport.Report.mix.writeReport (/Users/arusakov/myproject/node_modules/istanbul/lib/report/html.js:566:14)
at writeReport (/Users/arusakov/myproject/node_modules/karma-coverage/lib/reporter.js:62:16)
at /Users/arusakov/myproject/node_modules/karma-coverage/lib/reporter.js:290:11
Related npm modules:
"isparta-loader": "2.0.0",
"istanbul": "0.4.3",
"jasmine-core": "2.4.1",
"karma": "0.13.22",
"karma-coverage": "0.5.4",
"karma-jasmine": "0.3.8",
"karma-junit-reporter": "0.4.2",
"karma-phantomjs-launcher": "1.0.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "1.7.0",
"phantomjs-prebuilt": "2.1.7",
I had absolutely the same issue before, but I don't actually know how I fixed it. Just removed all node_modules and re-install again.
@viktordavidovich Reinstalling doesn't fix error in my case :(
Also see #660
Due to this error html report is not generated for some files in my case, but only when running subset of unit tests
+1
I am running into the same issue. I am running manual tests on instrumented JS code and have done setup to export coverage objects into json file. However, "istanbul report" does not seem to work and gives the same error as mentioned by @arusakov Any help appreciated!
+1
I spent the better part of the morning at work getting this to work. Here's what we did:
- Install the
babel-plugin-istanbul
module and configured exactly per recommendations. I.e., addedenv: { test: { plugins: ['istanbul'] }}
to our.babelrc
file and removed 'coverage' frompreprocessors
for our ES6 files. Note that I don't love this as it moves testing config from the karma file into babel, but it worked so I wasn't about to screw it up. - Install the
karma-coverage-istanbul-reporter
module and configure per recommendations and our existing setup. I.e., I removed ourcoverageReporter
property replacing withcoverageIstanbulReporter
and tweaking the props so they match the expected configuration schema.
New schema looks like this (extraneous bits removed):
webpackConfig.module.rules.push({
test: /\.es6/,
enforce: 'post',
exclude: /(test|node_modules)\//,
use: { loader: 'istanbul-instrumenter-loader', options: { esModules: true } }
})
const overrideConf = {
reporters: ['coverage-istanbul', 'mocha', 'junit'],
coverageIstanbulReporter: {
dir: '../coverage',
fixWebpackSourcePaths: true,
reports: ['cobertura', 'lcov', 'text', 'text-summary'],
skipFilesWithNoCoverage: true
},
mochaReporter: {
ignoreSkipped: true
},
autoWatch: false,
preprocessors: {
'./testImporter.karma.es6': ['webpack', 'sourcemap']
},
webpack: webpackConfig
}
And the relevant portions of package.json
(again, extraneous bits removed):
"babel-plugin-istanbul": "^4.1.5",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.0",
"karma-coverage": "^1.1.1",
"karma-coverage-istanbul-reporter": "^1.3.3",
@gotwarlost Come on guys? Let's get this fixed issue fixed and merged already.
As mentioned by @icfantv I managed to get rid of this issue by using karma-coverage-istanbul-reporter
I added these two to my karma config
coverageIstanbulReporter: {
dir: 'coverageReport/html/client',
reports: ['html', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: [
'progress',
'coverage-istanbul',
]
@saulve- can you please provide complete karma config file, bcz I am not able to generate coverage report in VSTS.
I've downgraded babel-plugin-istanbul
from 6.1.0
to 6.0.0
and it does not crash to me any more.
It did not crash before - with 6.1.0
- before my recent changes to the main code, so it looks to me sometimes babel-plugin-istanbul
can generate broken coverage data. However, I'm not sure how to reproduce this on smaller codebase.
So I cannot say if it's babel-plugin-istanbul
's fault or not, but consider version change as a possible work around.