question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enabling nyc to generate reports from coverage.raw.json

See original GitHub issue

Hi, I’d like to make a feature request.

If nyc can generate reports by only reading coverage.json, then it’d be convenient.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
ansjcycommented, Aug 20, 2020

After trying multiple nyc commands to produce the report from JSON with no luck, I found an interesting behavior of nyc: You have to be in the parent directory of the instrumented code when you are generating a report. For example: If the code I instrumented is in /usr/share/node/**, and the merged coverage.json result is in /tmp directory. If I run nyc report --temp-dir=/tmp --reporter=text under /tmp, I won’t get anything.

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------

But if I run the same command under /usr/share/node or /, I’m able to get the correct output with coverage numbers. Not sure if it’s a weird permission issue in nyc.

7reactions
jjangga0214commented, Dec 28, 2019

@coreyfarrell I just read nyc’s docs first time a few days ago. To me, it was unclear that nyc can generate reports from coverage.json.

For more reader-friendly docs(and for folks who do not know .nyc_output), how do you think an explicit mention on this feature with practical command usage example (like below)?

# this reads json coverage files from ./dir-containing-coverage-json 
# and generate html report
# to ./dir-for-report
nyc report \
  --temp-dir ./dir-containing-coverage-json \
  --reporter html \
  --report-dir ./dir-for-report
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to generate nyc report from json results (no . ...
It grabs the JSON files from the coverage directory and puts them altogether into an HTML report in the coverage/summary subdirectory.
Read more >
nyc - npm
Follow their documentation to enable and configure coverage reporting. Configuring nyc. nyc accepts a wide variety of configuration arguments, ...
Read more >
nyc/README.md
Coverage Status](https://coveralls.io/repos/bcoe/nyc/badge.svg?branch=)]( ... 107, 2. disable nyc's instrumentation and source-maps, e.g. in `package.json`:.
Read more >
Generate report from __coverage__ object
Output the contents of window.__coverage__ (assuming it's in Istanbul 1.0 format) to .nyc_output/out.json . To generate HTML report for example, run:
Read more >
cypress/code-coverage - npm Package Health Analysis
You can specify custom report folder by adding nyc object to the package.json file. For example to save reports to cypress-coverage folder, use:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found