We have a Quality Gates for our Angular 13 project, and we have to make our coverage more than 80%.
The problem is the SonarQube which lives on our dev server is ignoring the unit test files, it shows 'Coverage –'.
Is there a problem on our server and we need some changes in a config file maybe to work it, or it is a problem with our Angular project?
npm test
is generating the coverage folder, but the coverage folder is in our .gitignore
. "test": "ng test --code-coverage"
.
CodePudding user response:
We fixed it.
In the Angular project just set in the karma.conf.js
coverageReporter: {
dir: require('path').join(__dirname, './coverage'),
reports: ['lcovonly'],
subdir: '.',
reporters: [{ type: 'lcov' }],
},
run ng test --code-coverage
We are using docker, so sonar cli docker have to run this:
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info