Code coverage stopped working for typescript projects

This started happening on 22 Sep. A scan at Mon, 22 Sep 2025 10:06:38 GMT worked showed correct coverage, but our next one at Mon, 22 Sep 2025 10:40:59 GMT showed 0% coverage

No significant code change or sonar config change was made in this time. The change between these two runs was an update of code dependencies. I have tried reverting this change in a pull request and still get 0% coverage on the pull request.
It is also affecting other typescript projects we have (but have picked this one as its the smallest time window between it working and not working)

  • ALM used: Github
  • CI system used: Github actions
  • Scanner command used when applicable : github actions - SonarSource/sonarqube-scan-action@master (have also tried with v6.0.0)
  • Languages of the repository: typescript
  • Only if the SonarCloud project is public, the URL - SonarQube Cloud
    *
  • Error observed:
    Coverage is showing as 0%
    A scan at Mon, 22 Sep 2025 10:06:38 GMT worked showed correct coverage, but our next one at Mon, 22 Sep 2025 10:40:59 GMT showed 0% coverage
  • Steps to reproduce: run scan
  • Potential workaround: none

Hi @anthony-nhs,

can you share the full debug logs of the analysis, please?

Thanks!

Hi @anthony-nhs,

from what I see in the sonar properties of your project I see the problem. The JS/TS analyzer has dropped support for modules, as it was never fully supported (even if it worked in your case) and it was mostly for other scanners like Maven and dotnet. Can you please change your sonar properties to something like this:

sonar.organization=nhsdigital
sonar.projectKey=NHSDigital_eps-prescription-status-update-api
sonar.host.url=https://sonarcloud.io

sonar.coverage.exclusions=\
    **/*.test.*, \
    **/mock*, \
    **/jest.*.ts, \
    scripts/*, \
    release.config.js, \
    packages/common/commonTypes


sonar.javascript.lcov.reportPaths=packages/capabilityStatement/coverage/lcov.info,packages/checkPrescriptionStatusUpdates/coverage/lcov.info,packages/cpsuLambda/coverage/lcov.info,packages/gsul/coverage/lcov.info,packages/nhsNotifyLambda/coverage/lcov.info,packages/nhsNotifyUpdateCallback/coverage/lcov.info,packages/psuRestoreValidationLambda/coverage/lcov.info,packages/sandbox/coverage/lcov.info,packages/statusLambda/coverage/lcov.info,packages/updatePrescriptionStatus/coverage/lcov.info,packages/common/middyErrorHandler/coverage/lcov.info

Please let me know if that helps.

Sorry for the inconvenience

The reason we ended up using modules was to try and prevent file name clashes and things passing when they should not

Eg - we had

packages/module_1/src/handler.ts
packages/module_2/src/handler.ts

packages/module_1/src/handler.ts had 100% coverage

We make a change to packages/module_2/src/handler.ts so that the coverage on there drops below 80%

Sonar still shows it as working as in one of the lcov report files showed that src/handler.ts had 100% coverage

This still seems to be a problem - SonarQube Cloud

The new file packages/nhsd-psu-sandbox/src/handler.ts does not have any tests run for it but it shows as 100% coverage

Do you know a way we can work round this?

Hi @anthony-nhs,

we will revert the changes, you can expect the previous behavior from tomorrow.

Sorry for the inconvenience

I have worked around it by combining all the lcov.info files and rewriting the filenames in them to be full path using this script

#!/usr/bin/env bash
set -euo pipefail

output=coverage/lcov.info
mkdir -p coverage

true > “$output”

for pkg in packages/\*; do
if \[\[ -f “$pkg/coverage/lcov.info” \]\]; then
# Rewrite paths in lcov.info to be relative to repo root
sed “s|^SF:|SF:$pkg/|” “$pkg/coverage/lcov.info” >> “$output”
fi
done

which seems to have worked - when there is no coverage for a new file with the same name as in another module, it shows 0% coverage. When there is coverage for a new file it shows the correct coverag

should say on the above, when I do this I changed my sonar-project.properties to just have

sonar.javascript.lcov.reportPaths=coverage/lcov.info

Hi,

This should be fixed. Thanks for reporting it!

 
Ann

Thanks for the quick response. Everything seems to be working again for us