Sonar scanner has no coverage data with 2 jest shards

I am using sonarqube-scanner npm package version 2.7 in a gitlab pipeline. Now I am trying to separate the unit testing job in 2, creating 2 reports and loading them into sonarqube. I tried updating to the latest sonarqube-scanner version(4.2.5), but that version tries to detect a proxy which, to my knowledge, we don’t have.
I tried adding a new job, which merged the reports, but I had the same error. The strange thing is that the job ends successfully, but in MR it still shows ‘No data about coverage’.
I added a third party package to generate a report for the property sonar.testExecutionReportPaths and since then I get duplication data, but still no coverage data


Here my sonar config:


For privacy’s sake I replaced some key values in the log

sonar logs.txt (2.5 MB)

I expect it to be like this:

And here the logs when updating to 4.2.5:
sonar logs for npm 4.2.5.txt (6.6 KB)

Hi,

Welcome to the community and thanks for the thoroughness of this report!

I see this in your log:

14:51:34.059 WARN: Could not resolve 7 file paths in [/builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/cobertura-coverage-1.xml, /builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/cobertura-coverage-2.xml, /builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/shards/lcov-1.info, /builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/shards/lcov-2.info]
14:51:34.059 DEBUG: Unresolved paths:
src/app/config/api-paths.ts
src/app/definitions/core/global-api.definition.ts
src/app/definitions/features/kis/kis-api.definition.ts
src/app/definitions/features/mako/mako-api.definition.ts
src/app/definitions/features/tabellenpflege/tabellenpflege-api.definition.ts
src/app/definitions/features/verbrauchsstatistik/verbrauchsstatistik-api.definition.ts
src/app/definitions/features/vmp/vmp-api.definition.ts

So at least some file paths in the report aren’t recognized. The log says 1555 files are analyzed, but how many should be in the coverage report? All of them? Only 7? Something in between?

 
Thx,
Ann

Thank you for the prompt response! Every file, but those 7 get generated automatically so are not important for the coverage. Can you comment on the log when I update?
I also plan on creating a support ticket as soon as I can, since I have the developer edition

Hi,

I’m going to flag this for the language experts.

 
Ann

Hello @koestnei, thanks for the report.

According to the Sonar Scanner configuration file, you are declaring coverage reports in both LCOV and Cobertura formats. Note that only LCOV is supported by the JS analyzer, but it is resilient enough to not crash when encountering Cobertura reports.

In the logs, we see that 4 reports are actually found by the analyzer:

  • /builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/cobertura-coverage-1.xml
  • /builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/cobertura-coverage-2.xml
  • /builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/shards/lcov-1.info
  • /builds/[PROJECT_PATH]/[PROJECT_KEY]/coverage/jest/shards/lcov-2.info

Only the two last ones are considered to compute the coverage. Can you please check that these two reports only are enough to compute coverage?

Ideally, could you please share them with us? They don’t contain any sensitive information.

Thanks in advance,

Eric.

Hello Eric, I removed cobertura from the config and here are the reports:
lcov.zip (210.1 KB)

1 Like

and here the logs without cobertura
sonar logs NEW.txt (2.5 MB)

@koestnei , sorry for the delay. We are still trying to reproduce and identify the issue, and we may have a lead related to PR analysis.

I suspect that the issue would still happen if you push a new commit without the two Cobertura reports.

Can you give it a try?

1 Like

I guess you mean with just one lcov report? the logs without cobertura are in the previous comment

sonar logs without shards.txt (2.5 MB)
same issue. I also removed the sonar-report.xml(generated by an external package) report just in case

Hi @koestnei, sorry for the delay. We have been trying to reproduce your issue without success. Could you please put a public repository in place with a minimal reproducible example so that we can investigate and provide support?

That would be hard to arrange since the problem is with Sonarqubereporter.

My point is I could pull the minimal reproducible project that you share and analyze it with my own local instance of SonarQube to try and understand the issue.

I understand that, but it will take me a lot of time to create a minimal reproducible project. would It help to give you the angular and ts config?

Everything that could help us reproduce the issue is welcome. :slightly_smiling_face:

tsconfig.json (726 Bytes)

angular.json (7.8 KB)
tsconfig.spec.json (380 Bytes)

Turns out the config that I sent is correct. After using the jest shard option to separate the tests, I changed some of the code and then the reporter was shown as expected. When there is no changes in ts code the reporter show ‘No coverage data’ which is confusing, but not wrong.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.