Coverage is Always Zero
See original GitHub issueI have been trying to add coverage reporting for unit testing of a fresh Angular project for weeks with no success…
Would be great if someone could help me. 🙏
My karma.conf.js:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-coverage'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/TddBdd2020'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
// list of files / patterns to load in the browser
files: [
'**/src/**/*.js',
// 'test/spec/**/*.ts'
],
exclude: ['**/node_modules'],
preprocessors: {'**src/**/*.ts': ['coverage']},
reporters: ['coverage-istanbul'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
verbose: true
});
};
output:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
maven - SonarQube coverage is always 0 - Stack Overflow
As the title suggests, the coverage metric is always appears to be 0 in the SQ report (on my server) despite me having...
Read more >Code Coverage is showing 0% for java projects - SonarQube
Hi, We have recently upgraded our sonar application from 7.1 to 7.9.6 (LTS in 7.x). We have observed that code coverage is showing...
Read more >Code Coverage percentage is 0% in SonarQube Dashboard
We are trying to run theCode Coverage Pipeline job in Jenkins then we are getting the below error and the Coverage is showing...
Read more >Test coverage overview - SonarQube Documentation
Test coverage reports and test execution reports are important metrics in assessing the quality of your code.
Read more >Test Result and Code Coverage is not showing in SonarQube
0 Votes. Test Result and Code Coverage is not showing in SonarQube ... 2017-07-27T19:06:03.0202938Z 16:06:02.989 Fetching code coverage report information ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone else having this problem, I finally figured it out after finding this blog post.
In the end, I was able to use the default karma config file from a fresh
ng new
scaffold with no changes to the karma file at all.Just install the dependencies:
And then add the
--code-coverage
flag when running the tests:And now finally, it sees my files. 🎉
No, I am saying that you need to add something like karma-coverage to your config.