karma-runner / karma-coverage

A Karma plugin. Generate code coverage.
MIT License
770 stars 247 forks source link

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

Open Tin-Nguyen opened 9 years ago

Tin-Nguyen commented 9 years ago

I'm facing 1 issue on my Unit Test. It happens when I tried to add babelify into browerify's transform to convert ES6 in my implement code.

browserify: {
      transform: ['babelify', 'reactify', 'istanbulify'],
      extensions: ['.js', '.jsx'],
      debug: true,
      bundleDelay: 1000,  // WAR for karma-browserify race condition
},

I'm using:

Chrome 43.0.2357 (Mac OS X 10.10.2): Executed 313 of 324 (skipped 11) SUCCESS (0.515 secs / 0.313 secs)

ERROR [coverage]: [TypeError: Cannot read property 'text' of undefined] TypeError: Cannot read property 'text' of undefined at /node_modules/istanbul/lib/report/html.js:283:53 at Array.forEach (native) at annotateBranches (/node_modules/istanbul/lib/report/html.js:250:30) at HtmlReport.Report.mix.writeDetailPage (/node_modules/istanbul/lib/report/html.js:421:9) at /node_modules/istanbul/lib/report/html.js:484:26 at SyncFileWriter.extend.writeFile (/node_modules/istanbul/lib/util/file-writer.js:57:9) at FileWriter.extend.writeFile (/node_modules/istanbul/lib/util/file-writer.js:147:23) at /node_modules/istanbul/lib/report/html.js:483:24 at Array.forEach (native) at HtmlReport.Report.mix.writeFiles (/node_modules/istanbul/lib/report/html.js:477:23)

dignifiedquire commented 9 years ago

Could you either post a link to the code or supply a minimal example reproducing this please?

Tin-Nguyen commented 9 years ago

Hi @Dignifiedquire ,

I think I've provided all things on my post. Because the Unit Test still works well, and the report has been created/updated successfully. However, we got the error in end of progress.

And I just get the issue when I add babelify transform into the config. Have you checked with babelify yet?

Please let me know if you need to get what information from my case. I will investigate deeper on this issue today.

Regards, Tin Nguyen

Tin-Nguyen commented 9 years ago

Hi @Dignifiedquire , is there any updates on this? the issue still be my tests :((

dignifiedquire commented 9 years ago

Sorry I haven't gotten to it yet, will try to take a look later today

jljorgenson18 commented 9 years ago

+1

Tin-Nguyen commented 9 years ago

Hi @Dignifiedquire ,

I removed babelify, the report works fine. I really don't know the root cause. Could you help to check?

vectart commented 9 years ago

I switched to cheap-module-source-map and the issue is gone. Seems like incorrect sourcemap causes the failure while branch annotation.

SpenceDiNicolantonio commented 9 years ago

This appears to be an issue with Istanbul and source maps. See https://github.com/karma-runner/karma-coverage/issues/157#issuecomment-129636012.

dignifiedquire commented 9 years ago

Yes this seems to be the same issue as #157

icfantv commented 6 years ago

We had this error and I spent yesterday morning fixing. Here's a write-up of what worked for us.