Code coverage with GitLab CLI

I am wondering how to setup code coverage for reports that are automated with Gitlab Cli.

Is there any documentation for do this?

Also I am wondering about time.

I mean that for run coverage I need to perform:

  • npm install
  • npm run test - to generate an lcov coverage report used later by sonar scanner

Above takes to much time (about 20 minutes npm install and 10 minutes running tests)
Assuming that this is run for all commit in merge requests it is very long time.

Is there any better solution?

Ideally, you already have a build where you’re running your tests on every commit. By just adding SonarQube to that build, you don’t have to run your tests again, just use the report that has already been generated.

No I have not a build running unit tests on each commit. The pipeline running unit tests runs only once right before merge. So I have not result of test after each commit.