I have two projects (actually, a project and its sidecar) in the same repository - the server (root) and aux/sidecar (at aux/sidecar folder). I generate coverage for them using jest --coverage
calls, which generates lcov.info
files, which are located at coverage/lcov.info
and aux/sidecar/coverage/lcov.info
. I would like to merge them into a single report, so it could be uploaded to sonarqube and we could see the consolidated coverage for the whole repository.
I found lcov-result-merger tool, but I couldn't make it work as expected. I tried the following script on my package.json:
"merge-coverage": "lcov-result-merger 'coverage/lcov.info' 'aux/sidecar/coverage/lcov.info' coverage/lcov.info",
My idea was to put all results into the root project's result. However, when running this line, it seems that the third argument is ignored (I think it only expects two arguments).
I also tried the following (creating a pattern - that I'm not sure it is correct - that would grab both files):
"merge-coverage": "lcov-result-merger './**/**/coverage/lcov.info' 'coverage/lcov.info'",
But it also didn't work as expected (my sonarqube still shows 0% coverage).
I wonder if there is any other option - maybe something to fix my scripts, but I'm also open to other tools that would do the trick.
Here is an answer that does not answer your question, but that answers your need to push coverage to SonarQube: sonar.javascript.lcov.reportPaths
accepts multiple paths, separated by a comma. You don't need to merge your LCOV files. SonarQube will merge them for you.