Issue: Sonarqube coverage is 0% after i configured karma and sonar.
Arch: Application use Angular7 and Node v8.14, the integrated Sonarqube is the latest version and JDK is java 11.
Issue Desc: these are my local environment, after i configured and run coverage and sonar, karma coverage is 35% but in sonar it's still 0%.
Please see my code as below:
package.json
:
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test --code-coverage",
"lint": "ng lint",
"e2e": "ng e2e",
"sonar": "sonar-scanner"
},
"dependencies": {
...
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"puppeteer": "^2.0.1"
},
"devDependencies": {
...
"sonarqube-scanner": "^2.6.0",
}
sonar-project.properties
:
sonar.projectKey=aaa
sonar.projectName=AAA
sonar.projectVersion=1.0.0
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.test.reportPath=./test-results.xml
sonar.language=ts
sonar.exclusions=**/node_modules/**
sonar.tests=src
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.test.inclusions=**/*.spec.ts
karma.conf.js
:
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
// browsers: ['ChromeHeadless'],
// singleRun: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
...
calss structure