I've been working on setting up SonarQube for my Angular 6 project. I have successfully run 5 basic tests and the Karma coverage report is as follows:
Chrome 92.0.4515 (Windows 10.0.0): Executed 5 of 5 SUCCESS (0.807 secs / 0.868 secs)
=============================== Coverage summary ===============================
Statements : 29.65% ( 282/951 )
Branches : 23.37% ( 115/492 )
Functions : 16.84% ( 32/190 )
Lines : 28.2% ( 258/915 )
================================================================================
However, when I set up SonarQube locally to view the coverage report, it always shows 0% coverage.
Since Karma shows some coverage results, I expect Sonar's coverage to be at least somewhat similar.
Here is the content of the sonar-project.properties file:
sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin123
sonar.projectKey=myproject:ui
sonar.projectName=Sample App
sonar.projectVersion=0.0.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions=**/node_modules/**
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.typescript.lcov.reportPaths=coverage/myproject/lcov.info
And here is a snippet from the package.json file:
"scripts": {
"sonar": "sonar-scanner"
},
"devDependencies": {
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"sonar-scanner": "^3.1.0",
}
The lcov.info file can be found under src/coverage/myproject/lcov.info.
After running npm run sonar
, the coverage in SonarQube still shows 0.0%. Any assistance in resolving this issue would be greatly appreciated.