Using Jest v28 --shard
flag significantly speeds up tests in our CI/CD pipeline, but it creates the issue of having to merge multiple coverage reports into a single file (required for our code quality report on PRs).
I am forced to use lcov
format for the coverage report. I am able to merge the coverage report using lcov
CLI tool:
lcov --add-tracefile ./coverage-unit/lcov-1.info --add-tracefile ./coverage-unit/lcov-2.info --output-file ./coverage-unit/lcov.info
But the merged ./coverage-unit/lcov.info
file does not pick up the branch data:
Combining tracefiles.
Reading tracefile ./coverage-unit/lcov-1.info
Reading tracefile ./coverage-unit/lcov-2.info
Writing data to ./coverage-unit/lcov.info
Summary coverage rate:
lines......: 87.9% (5003 of 5691 lines)
functions..: 85.4% (543 of 636 functions)
branches...: no data found
This results in a merged lcov.info
that is omitting the BRH
, BRF
, and BRDA
fields.
Is there a proper way to merge lcov
report files?