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

Broken HTML report when merging coverage info with nyc report #1011

Closed
bennycode opened this issue Mar 6, 2019 · 3 comments
Closed

Broken HTML report when merging coverage info with nyc report #1011

bennycode opened this issue Mar 6, 2019 · 3 comments
Labels

Comments

@bennycode
Copy link

Link to bug demonstration repository.

Expected Behavior

HTML report where you can click on files to see their code coverage.

Observed Behavior

HTML report which is broken for some of the files:

TypeError: Cannot read property 'locations' of undefined

image

Scenario

  • I wrote TypeScript code which behaves differently depending on the environment (Node.js or a HTML5 browser) it runs on.
  • To test every part of my code, I need to run tests in a Browser environment and in a Node.js environment.
  • For running tests in Node.js, I am using nyc in combination with jasmine and ts-node/register.
  • Browser tests are performed by karma with karma-jasmine and karma-chrome-launcher.
  • When I execute the browser tests in my project (yarn test:browser), I am getting HTML output (coverage/browser/html) and JSON output (coverage/json/coverage-browser.json). The HTML report works fine. I can see my TypeScript files in the report and their coverage.
  • When I execute the Node.js tests in my project (yarn test:node), I am also getting HTML output (coverage/node/html) and JSON output (coverage/json/coverage-final.json). The HTML report looks fine here too!
  • The code coverage of my browser tests report that half of my code is covered by tests.
  • The code coverage of my Node.js tests report that the other half of my code is covered.

I would like to join both code coverage reports now to receive one universal (merged) report that states that my app code is fully covered by tests.

I have read documentation on nyc merge and thought it is a good idea to run nyc report (which implicitly merges coverage information) and point it to my JSON output files:

nyc report --temp-dir coverage/json --report-dir=coverage/merged/html --reporter=html

The nyc report command finishes and I am receiving an HTML report but the report is broken (see "Observed Behavior"). I would like to know what is going wrong there because when I check the individual HTML reports (coverage/browser/html & coverage/node/html) they look fine.

Forensic Information

Operating System: Windows 10 Pro (but I think the problem is unrelated to the OS)
Environment Information:

  • Node.js v10.9.0
  • npm v6.4.1
@stale
Copy link

stale bot commented May 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 5, 2019
@coreyfarrell
Copy link
Member

Closing here in favor of istanbuljs/istanbuljs#322.

@filame
Copy link

filame commented Aug 14, 2019

I do not use karma and have the exact same issue with merging coverage files.
I use cypress and jest and want to merge their coverage outputs.
What happens is exactly what was described by @bennyn.

I use:

  • jest 24.8.0
  • cypress 3.4.1
  • istanbul-lib-coverage 2.0.5
  • nyc 14.1.1

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

No branches or pull requests

3 participants