Coverage reports not part of Pull Request quality gates

Hello all

I’ve run into a weird and very tiresome issue regarding our integration between SonarCloud and Azure DevOps. The integration between the two platforms work fine, we receive comments etc from our PRs, however i for whatever reason cannot get the Coverage gate to fail if no test coverage is provided.

The setup for our TypeScript/Javascript projects care creating coverage reports using Jest and follow this setup: JavaScript/TypeScript Test Coverage | SonarCloud Docs

In short we create coverage reports (lcov.info) and set the property: sonar.javascript.lcov.reportPaths=./coverage/lcov.info

This seems to work fine when a sonarcloud project is analysed on the main branch as it clearly display our test report in the project. However, for some reason i cannot get any results when we create PR for a project. The code coverage is always 0%, and the gate never fails, but the test report is generated and published.

Why is it that it seems to work fine for our main branch, but the PRs simply both isn’t failing the coverage gate (even though my quality gates states they should) and seems to ignore the report generated?

I am at a lost :frowning:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Languages of the repository: Typescript/javascript
  • Potential workaround: Seems to work using this guide: https://javascript.plainenglish.io/making-sonarcloud-play-nicely-with-jest-fa271f559024 (tldr: nodejs lib: jest-sonar-reporter creates a report that is set by property: “sonar.testExecutionReportPaths=./test-report.xml” - however this also breaks all pipelines where jest/test isn’t setup yet as the file isn’t create here and the Sonarcloud publish step fails as it cannot find the specified file. )

BR, Steffen

Hey there.

Can you take a screenshot of what you’re using in SonarCloud – where coverage is reported as 0% (except on the main branch where it is working) but the Quality Gate isn’t failing?

Hi Colin!

For whatever reason i’ve seem to have it working now. My PRs now correctly fails my coverage quality gate when new code is provided in a PR. I am not quite sure why, it might be caused by my Quality Gate settings needed some time to correctly apply my changes (i’ve added coverage again as a gate during my fiddling with our setup, as we previously had remove it)

Hopefully it works now.
Sorry for any inconvenience!

BR Steffen

1 Like

Glad to hear you’re in good shape.

Quality Gate changes should take effect immediately (and, will require a new analysis after any changes). Hopefully we can call this a fluke, but we’ll keep our eyes out for any other similar reports.

Thanks for the follow-up!