Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.1.0-alpha.1] Cannot read property 'text' of undefined in HTML report #660

Open
MatthiasF999 opened this issue Jul 5, 2016 · 10 comments

Comments

@MatthiasF999
Copy link

MatthiasF999 commented Jul 5, 2016

Trace
Cannot read property 'text' of undefined
TypeError: Cannot read property 'text' of undefined
    at H:\projects\general\modulemanager\node_modules\istanbul-reports\lib\html\annotator.js:149:59
    at Array.forEach (native)
    at annotateBranches (H:\projects\general\modulemanager\node_modules\istanbul-reports\lib\html\annotator.js:112:30)
    at Object.annotateSourceCode (H:\projects\general\modulemanager\node_modules\istanbul-reports\lib\html\annotator.js:191:9)
    at HtmlReport.onDetail (H:\projects\general\modulemanager\node_modules\istanbul-reports\lib\html\index.js:217:39)
    at LcovReport.(anonymous function) [as onDetail] (H:\projects\general\modulemanager\node_modules\istanbul-reports\lib\lcov\index.js:24:24)
    at Visitor.(anonymous function) [as onDetail] (H:\projects\general\modulemanager\node_modules\istanbul-lib-report\lib\tree.js:34:30)
    at ReportNode.Node.visit (H:\projects\general\modulemanager\node_modules\istanbul-lib-report\lib\tree.js:123:17)
    at H:\projects\general\modulemanager\node_modules\istanbul-lib-report\lib\tree.js:116:23
    at Array.forEach (native)
    at visitChildren (H:\projects\general\modulemanager\node_modules\istanbul-lib-report\lib\tree.js:115:32)
    at ReportNode.Node.visit (H:\projects\general\modulemanager\node_modules\istanbul-lib-report\lib\tree.js:126:5)
    at Tree.visit (H:\projects\general\modulemanager\node_modules\istanbul-lib-report\lib\tree.js:158:20)
    at H:\projects\general\modulemanager\node_modules\istanbul-api\lib\reporter.js:84:18
    at Array.forEach (native)
    at Object.Reporter.write (H:\projects\general\modulemanager\node_modules\istanbul-api\lib\reporter.js:82:35)
    at exitFn (H:\projects\general\modulemanager\node_modules\istanbul-api\lib\run-cover.js:169:18)
    at process.g (events.js:286:16)
    at emitOne (events.js:101:20)
    at process.emit (events.js:188:7)
    at process.exit (internal/process.js:146:15)
    at done (H:\projects\general\modulemanager\node_modules\mocha\bin\_mocha:417:32)
    at afterWrite (_stream_writable.js:361:3)
    at _combinedTickCallback (internal/process/next_tick.js:80:20)
    at process._tickCallback (internal/process/next_tick.js:98:9)
relevant package.json
  "scripts": {
    "coverage": "node_modules/.bin/istanbul cover node_modules/mocha/bin/_mocha test -- --compilers js:babel-register --require babel-polyfill"
  },
  "dependencies": {
    "callsite": "^1.0.0"
  },
  "devDependencies": {
    "babel-cli": "^6.10.1",
    "babel-plugin-transform-class-properties": "^6.9.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-export-extensions": "^6.8.0",
    "babel-plugin-transform-function-bind": "^6.8.0",
    "babel-polyfill": "^6.9.1",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-stage-2": "^6.5.0",
    "babel-register": "^6.9.0",
    "chai": "^3.5.0",
    "istanbul": "^1.1.0-alpha.1",
    "mocha": "^2.5.3",
    "nodemon": "^1.9.2",
    "sinon": "^1.17.4",
    "sinon-chai": "^2.8.0"
  }

I can only test this with istanbul@next, since the stable version delivers an empty coverage report.

@gotwarlost
Copy link
Owner

That message usually means that the source text for a file does not match what was instrumented.

Is there a way you can provide a basic failing case in a gist or something?

@MatthiasF999
Copy link
Author

Well, I found the mistake.

It is a problem with babel not generating sourcemaps when not told via command (.babelrc doesn't work in this case).

@taozhi8833998
Copy link

have the same issue +1

@HipsterZipster
Copy link

@MatthiasF999 How did you solve?

@MatthiasF999
Copy link
Author

You need to remove

"sourceMaps": true

from the .babelrc file.
That solved it for me.

@levity
Copy link

levity commented Sep 14, 2016

I have the same issue and don't have "sourceMaps": true in my .babelrc file.

@amygdaloideum
Copy link

In my case this problem was casused by running istanbul after browserify-ngannotate in browserify transforms.

@levity
Copy link

levity commented Oct 3, 2016

I created a patch for this issue: istanbuljs-archived-repos/istanbul-reports#10

@aldoshin
Copy link

For those working with webpack, you can find this useful:

webpack-contrib/istanbul-instrumenter-loader#32

Basically work with older version of "istanbul-instrumenter-loader": "0.2.0"

@LoganBarnett
Copy link

I ran into this problem in my Webpack setup. Making istanbul-instrumenter-loader the inner most (last) loader in the chain for my files helped make it work. Also I added sourceMaps: true as a babel option. This is using istanbul-instrumenter-loader 2.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants