简体   繁体   中英

Merging coverage reports from nyc

I have a CI running that does mocha test executions in parallel. A test execution creates a coverage report coverage.json - generated by nyc . I want to have a final merged report from all of the coverage.json s in lcov format, but I can't manage to generate one - I always end up having an empty text summary. What I've tried:

  1. Running nyc report :
nyc report --temp-dir=nyc/coverage_dir --reporter=text --reporter=lcov 

gives an empty report and text summary

  1. First running nyc merge and then nyc report
nyc merge ./coverage_dir coverage.json
nyc report --report-dir=temp --reporter=text --reporter=lcov

This combination does seem to merge the coverage.jsons files, at least judging from the file size, but the report step still displays an empty text summary.

  1. Trying the above with different version, ie nyc 15.1.0 and nyc 14.1.1
  2. Specifying the -t flag and --report-dir options outlined in this answer
  3. Changing to a parent directory and rerunning the commands as specified by this answer .

All resulting in an empty text summary of the final report.

I solved it in this way.

Copy all the json files in the default folder:

mkdir .nyc_output
cp project_a/coverage/coverage-final.json .nyc_output/project_a.json
cp project_b/coverage/coverage-final.json .nyc_output/project_b.json

Then generate the report:

nyc report --reporter=text --reporter=lcov --report-dir=destination-dir

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM