SonarCloud not recognising Javascript lcov coverage report

Template for a good new topic, formatted with Markdown:

  • CI system used GitLab CI
  • Scanner command used when applicable: sonar-scanner
  • Languages of the repository: javascript
  • Error observed: No error as such, coverage reports 0%

I have a JavaScript project using Jest for testing, and jest-sonar-reporter for the coverage reports. This outputs to coverage/lcov.info which is in my sonar-project.properties file as follows:
sonar.javascript.lcov.reportPaths=coverage/lcov.info but on the SonarCloud UI it is showing coverage as 0% but when looking at the output from running the tests it should be an overall figure of 70.21% lines

1 Like

I haven just noticed this in the debug logs:
15:37:57.115 DEBUG: ‚ÄėJavaScript analysis‚Äô skipped because there is no related file in current project
15:37:57.116 DEBUG: ‚ÄėSonarJS Coverage‚Äô skipped because there is no related file in current project

This is my sonar-project.properties file:

sonar.host.url=https://sonarcloud.io
sonar.projectKey=<PROJECT-KEY>
sonar.organization=lb-dev
sonar.testExecutionReportPaths=test-report.xml
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.tests=src

Welcome to the community, sorry for the late answer!

This is the most important hint to understanding the problem:

It seems that no JavaScript source files were found during the analysis, given your configuration. The most relevant configuration properties are sonar.sources, sonar.inclusions, and sonar.exclusions. Please review these and related settings, as well as the Narrowing The Focus page in our documentation.

For a simple sanity check, it may help to run a scan with -Dsonar.sources=.

I hope this helps!