Has anyone managed to combine test coverage report from two separate jest test runs?
I am newbie trying to use the default jest coverage reporters: ["json", "lcov", "text", "clover"]
I have tried using nyc
to combine coverage-final*.json
files from tmp folder and output to a full-test-coverage/
folder.
npx nyc report --report-dir=full-test-coverage/ --reporter=html -t tmp
The full-test-coverage folder is created with index.html etc. However, the combined report is empty.
I was struggling with this too but I managed to do it by using the istanbul-merge package
So assuming that you want to merge two test coverage named coverage-final.json
located in two different folders f1
and f2
,and name the output f3/coverage.json
you can do :
npx istanbul-merge --out coverage.json ./f1/coverage-final.json ./f2/coverage-final.json
and then use instanbul to create the HTML report :
npx istanbul report --include coverage.json --dir f3 html