5

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.

skyboyer
  • 22,209
  • 7
  • 57
  • 64
Vasanth Kumar
  • 311
  • 1
  • 3
  • 9

2 Answers2

5

A dumb mistake from myside.

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

Vasanth Kumar
  • 311
  • 1
  • 3
  • 9
  • 1
    The docs say you can use `sonar.javascript.lcov.reportPaths` for both js and ts. https://docs.sonarqube.org/latest/analysis/coverage/ – JBS Aug 30 '21 at 09:01
  • As of this year (2023) `sonar.typescript.lcov.reportPaths` has been deprecated – CWSites Apr 25 '23 at 14:53
-1

can you share console output of the jenkins job?

in my case, jenkins cannot find the coverage report and got log in console output like this :

15:26:37  [ERROR] Coverage report '/home/jenkins/workspace/microservices-pipelines/xxx/target/jacoco.exec' could not be read/imported. Error: {}
15:26:37  java.lang.IllegalStateException: Failed to parse JaCoCo XML report: /home/jenkins/workspace/microservices-pipelines/xxx/target/jacoco.exec
Fauzan
  • 654
  • 1
  • 7
  • 15