Search code examples
sonarqubejestjssonarscanner

Sonarqube coverage 0% in react js


I have written some unit tests in jest. All of them are successful. Able to view test coverage report generated by jestenter image description here

But my sonarqube dashboard always shows 0% on coverage but unit tests are being detected.

enter image description here

I am using jest-sonar-reporter for sonar consumable format generation of reports.

This is my sonar properties file

sonar.projectKey=skyflow-app
sonar.projectName=Skyflow App
sonar.host.url = http://localhost:9000
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions=**/node_modules/**,**/*.spec.ts, **/*.stories.tsx
sonar.tests=src
sonar.test.inclusions=**/*.test.tsx,**/*.test.ts
sonar.test.exclusions=**/*.stories.tsx
sonar.ts.tslintconfigpath=tslint.json
sonar.testExecutionReportPaths=testResults/sonar-report.xml
# sonar.coverageReportPaths = coverage/lcov.info
sonar.javascript.lcov.reportPaths = coverage/lcov.info

Please let me know where i am going wrong.


Solution

  • A dumb mistake from myside.

    Replacing sonar.javascript.lcov.reportPaths with sonar.typescript.lcov.reportPaths solved the issue.