SonarCloud - Coverage inconsistency between SonarCloud and local coverage reports

  • ALM used (Bitbucket Cloud)
  • CI system used (Circle CI)
  • Languages of the repository: JavaScript/TypeScript

We’ve encountered a coverage inconsistency between our local reports generated by nyc and SonarCloud analysis, and we seek assistance to understand and resolve this issue.

In our CircleCI pipeline, we run parallel test suites for unit (jest) and component (cypress) tests. Each suite generates a nyc lcov report, all of which are passed to Sonar using the Sonar Orb sonarcloud/scan job. While our local reports indicate 100% coverage, SonarCloud is highlighting some lines as uncovered, resulting in coverage that is less than 100%.

One example is a line that is not covered by the unit tests, but is covered by the component tests. So in this case it would appear that it is the component (Cypress) coverage that SonarCloud is not fully reading. However, there is another file that is covered fully by unit tests but that is also showing incorrectly. So we are unable to identify any clear patterns.

We have performed logging and debugging with breakpoints that show the lines are being hit by our tests.

What can we do to understand why this is happening?


Welcome to the community!

This might help: