karma-coverage: karma coverage does not show any data
I have included the source files in the files & preprocessors section of my karma conf file. The tests run fine and the junit xml report shows the data. The html coverage just show 100% without any data. I have the similar structure for another project which is working fine but not this one. Not sure if i am missing something. Might be a very minor or silly thing i have missed.
karma.conf.js:
module.exports = function (config) {
config.set({
basePath: '../../',
frameworks: [
'jasmine'
],
// list of files / patterns to load in the browser
files: [
'app/js/**/*.js',
'test/spec/**/*.js'
],
preprocessors: {
'app/js/**/*.js': ['coverage']
},
exclude: [],
reporters: [ 'progress', 'junit', 'coverage' ],
coverageReporter: {
type: 'html',
dir: 'test/reports/unit/coverage'
},
junitReporter: {
outputFile: 'test/reports/unit/junit/junit.xml',
suite: 'unit'
},
port: 9876,
runnerPort: 9100,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: false,
browsers: [ 'Chrome' ],
captureTimeout: 60000,
singleRun: true
});
};
my karma conf file is in test -> spec -> conf and source files are in app -> js -> controllers/directives/services
the debug log shows its loading all the files in preprocessors but the report does not show any data “No data to display”.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 53 (8 by maintainers)
I’ve had similar issue with browserify + babel + karma. Take a look here.
Key to my setup was to add [“istanbul”] into babel plugins.
I’m not totally sure how related this is but after running into the same issues as others on this thread I looked back into a project I worked on that had this working.
The vital config for me was to require browserify-istanbul in my karma.config.js:
and set this config:
Not totally sure what this points to other than a possible issue with karma-browserify perhaps, but maybe it can help someone…
I think the issues is that you are missing the source files, in the
filesarray, try something like this:hi friend this problem already solved in the karma config just change preprocessor to
preprocessors: { ‘**/*.js’: ‘coverage’ },
100% will solve your problem
I ran into this issue when using rollup + babel + karma.
I fixed it by using
"istanbul"as a babel plugin, as suggested above.Then, use babel as a karma plugin, and do not include
rollup-plugin-istanbul.I was facing the same issue. My Debug Log showed that files were being processed, however a coverage report was not being generated. I solved this by setting the includeAllSources flag to true in my coverageReporter. Hope that helps!
coverageReporter: { dir: 'report/', includeAllSources: true },So, somehow, without me touching anything related to karma-coverage, it started to generate lcov.info a few commits later. I have no idea what caused this, kind of stochastic behaviour if you ask me. Might it be related to one of my jasmine tests failing? but that should not matter right? weird.