Sonarcloud for typescript project showing 0 coverage

hey guys, i have a step in my bitbucket pipeline which runs SonarCloud analysis scan for my typescript project,
by the end of the pipeline run it shows SonarCloud analysis was successful, but sonarcloud dashbord always showing 0 coverage

the pipeline step-

  • step:
    name: Unit tests
    caches:
    - node-modules
    - yarn
    - sonar
    script:
    - cd next_app
    - yarn install
    - yarn jest --coverage
    - pipe: sonarsource/sonarcloud-scan:1.2.1
    variables:
    SONAR_TOKEN: ${SONAR_TOKEN}

my jest configuration on package.json-
“jest”: {
“testPathIgnorePatterns”: [
“/.next/”,
“/node_modules/”
],
“collectCoverage”: true,
“coverageDirectory”: “./coverage”,
“testResultsProcessor”: “jest-sonar-reporter”
},

sonar-project.properties file-
sonar.sources=.

sonar.tests=src

sonar.test.inclusions=’/testing/,/*.spec.ts,/*.spec.tsx’

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

sonar.testExecutionReportPaths=./test-report.xml

any help will be much appreciated!

Hi @Gili_Shem , as of August 16th the property for typescript coverage got deprecated in favor of sonar.javascript.lcov.reportPaths and you have to replace it in your pipeline step. You can read more about coverage in our documentation.

Please, let us know if that works or if there’s anything else we can help you with!

Best regards,
Antonio

Hi Antonio Garcia

I faced similar issue: Sonarcloud- shows 0 coverage for Typescript (Using AzureDevOps Pipeline)

I am using ADO pipeline for running the tasks. Appreciate your assistance on this.

I’m also running SonarCloud Code coverage for Typescript via AzureDevOps Pipeline and SonarCloud Dashboard Coverage is still showing 0.0% Code in spite of, having correct paths on sonar properties like sonar.javascript.lcov.reportPaths=coverage/lcov.info, cliSources, etc., and there are contents in lcov.info file. Enabled verbose output for debugging and verified the lists and path matches correctly.

The result of the raw log file returns 0 source files analyzed:

DEBUG Using ‘D:\a\1\s\app\code\coverage\lcov.info’ to resolve LCOV files
INFO Analysing [D:\a\1\s\app\code\coverage\lcov.info]
INFO Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=130ms
INFO Sensor IaC Docker Sensor [iac]
INFO Sensor IaC Docker Sensor is restricted to changed files only
INFO 0 source files to be analyzed
INFO 0/0 source files have been analyzed

Please share if ever you’ve solved this issue. Thank you.

This has been solved by fixing the content in lcov SF paths