Code coverage for TypeScript project not working

I am trying to add test coverage to my GitHub Action workflow that uses sonarcloud-github-action@v1.9. Basically I have a monorepo-ish repository where each subdirectory is a separate npm typescript project. I am currently running the sonar cloud analysis just fine as a single project, but the analysis complains about test coverage (since I haven’t set it up yet).

Let’s call the repository exampleproject and the component rest-api to protect sensitive information, / is the repository root.

  1. The build process for rest-api will append rest-api/ to all the file paths in lcov.info so that they match what sonar expects (same paths as I can see for the tests in SonarCloud GUI) and then save it to /sonar-coverage/lcov-rest-api.info. I have verified with ls in the Sonar job that the file exists and I have downloaded it from artifacts to verify that it is correct.
  2. Then sonarcloud-github-action will run with parameters -Dsonar.organization=exampleorg -Dsonar.projectKey=exampleorg_exampleproject -Dsonar.coverage.javascript.lcov.reportPaths=sonar-coverage/lcov-rest-api.info -X.
  3. The whole process ends successfully, but the sonarcloud comment in the PR still says “No Coverage information”.

The only hint I can find in the DEBUG logs of the Scan step is DEBUG: 'JavaScript/TypeScript Coverage' skipped because one of the required properties is missing. How do I figure out which property is missing?

sonar.coverage.javascript.lcov.reportPaths. You can find the correct parameter in the documentation on Test Coverage Parameters, specifically sonar.javascript.lcov.reportPaths.

1 Like

Gah. I’ve stared myself blind on that damn property and still didn’t catch it.

I still get no test coverage, but now the coverage scan is at least run. Need to investigate further.

Thanks!

1 Like