SonarQube is not picking cobertura coverage report

Cobertura report cobertura-coverage.xml is being generated in nodejs project. But Sonarqube is not picking up the cobertura coverage report. Sonar dashboard displays the coverage as 0 %.
versions used SonarQube - 6.7.5, Cobertura plugin 2.0)

Configuration used in package.json:
“scripts”: {
“start”: “react-scripts start”,
“build”: “react-scripts build”,
“test”: “react-scripts test”,
“eject”: “react-scripts eject”,
“coverage”: “npm test – --coverage --watchAll=false”,
“lint”: “eslint --ext ts,tsx src”,
“sonar”: “node sonar-project.js”
},
“jest”: {
“collectCoverageFrom”: [
“src/**/*.{ts,tsx}”,
“!/node_modules/”,
“!/src/serviceWorker.ts”,
“!/src/index.tsx”
],
“coverageReporters”: [
“text”,
“cobertura”,
“html”
]
},

Configuration used in sonar-project.js:
const sonarqubeScanner = require(‘sonarqube-scanner’);
sonarqubeScanner({
serverUrl: ‘http://:9000’,
options : {
‘sonar.sources’: ‘.’,
‘sonar.inclusions’ : ‘src/**’, // Entry point of your code
‘sonar.js.coveragePlugin’ : ‘cobertura’,
‘sonar.dynamicAnalysis’ : ‘reuseReports’,
‘sonar.cobertura.reportPath’ : ‘.\coverage\cobertura-coverage.xml’
}
}, () => {});

command used to install sonar-scanner:
npm install sonarqube-scanner --save-dev

reference url: How to integrate sonar for a Node JS project? - Arjunphp

I do not see cobertura sensor triggered in the sonar analysis logs.

Sensor SonarCSS Metrics [cssfamily]
INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=91ms
INFO: Sensor SonarCSS Rules [cssfamily]
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=12041ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
INFO: Sensor SonarJS [javascript]
INFO: 2 source files to be analyzed
INFO: Sensor SonarJS [javascript] (done) | time=484ms
INFO: Sensor ESLint-based SonarJS [javascript]
INFO: 2/2 source files have been analyzed
INFO: 2 source files to be analyzed
INFO: Sensor ESLint-based SonarJS [javascript] (done) | time=15010ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=2ms
INFO: Sensor HTML [web]
INFO: 2/2 source files have been analyzed
INFO: Sensor HTML [web] (done) | time=14ms
INFO: Sensor SonarTS [typescript]
INFO: Analyzing 43 typescript file(s) with the following configuration file tsconfig.json
INFO: 43 files analyzed out of 43
INFO: Sensor SonarTS [typescript] (done) | time=14896ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=59ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: SCM provider for this project is: git
INFO: 4 files to be analyzed
INFO: 4/4 files analyzed
INFO: 8 files had no CPD blocks
INFO: Calculating CPD for 37 files
INFO: CPD calculation finished
INFO: Analysis report generated in 549ms, dir size=250 KB
INFO: Analysis reports compressed in 561ms, zip size=140 KB
INFO: Analysis report uploaded in 29ms
INFO: ANALYSIS SUCCESSFUL,

Not sure what is still missing. Any help is appreciated.
Thanks!

Cobertura is a community plugin. Try to find the way to communicate your problem to the developers of this plugin.

1 Like

@Blessie7 - Did you get any resolution for this issue?

@CodingManager , please don’t bump old threads. Open a new one and describe your issue.

Okay. Anyway i found the solution to make it work.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.