karma-coverage icon indicating copy to clipboard operation
karma-coverage copied to clipboard

Karma coverage empty with a simple sample

Open njleonzhang opened this issue 7 years ago • 11 comments

sample project: https://github.com/njleonzhang/karma-study/tree/master/karma-2

Here is the config file:

// Karma configuration

module.exports = function(config) {
  config.set({
    // plugins
    plugins: [
      'karma-phantomjs-launcher',
      'karma-coverage'
    ],

    // list of files / patterns to load in the browser
    files: [
      'src/index.js',
      'test/index.js'
    ],

    reporters: ['coverage'],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'src/index.js': ['coverage']
    },

    coverageReporter: {
      dir: './coverage',
      // includeAllSources: true,
      reporters: [
        { type: 'lcov', subdir: '.' },
        { type: 'text-summary' }
      ]
    },

    // enable / disable colors in the output (reporters and logs)
    colors: true,
    .....
}

result:

=============================== Coverage summary===============================
Statements   : 100% ( 0/0 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 0/0 )
Lines        : 100% ( 0/0 )
================================================================================

version: "karma": "^1.7.1", "karma-coverage": "^1.1.1",

njleonzhang avatar Sep 18 '17 06:09 njleonzhang

I am too facing the same problem.

nimeshnikum avatar Oct 04 '17 13:10 nimeshnikum

same problem here

richistron avatar Apr 02 '18 18:04 richistron

Same problem here since webpack 4

mxchange avatar Jul 05 '18 11:07 mxchange

just add babel-plugin-istanbul to my project in this commit https://github.com/njleonzhang/vue-data-tables/commit/51aab5a53ef5b36d5d4385b73e47e196058d77ec, and the coverage works now.

njleonzhang avatar Jul 06 '18 01:07 njleonzhang

I am also dealing with that.

vkiperman avatar Aug 15 '18 19:08 vkiperman

I am also dealing with that and I added babel-plugin-istanbul.

pfzhengd avatar Jul 01 '19 09:07 pfzhengd

I am also dealing with that and I added babel-plugin-istanbul. My problem is solved because the 'include' path in 'babel-loader' is incorrect.

pfzhengd avatar Jul 02 '19 02:07 pfzhengd

I am also having this issue. Would be great if the karma docs described how to actually add coverage reports... 😥

JimLynchCodes avatar Mar 14 '20 02:03 JimLynchCodes

bump! 🙃

JimLynchCodes avatar Mar 16 '20 03:03 JimLynchCodes

Try the debug logging, maybe that gives a hint.

johnjbarton avatar Mar 16 '20 19:03 johnjbarton

Thanks @johnjbarton!

Unfortunately, the debug logging didn't give me any hints. 😥

For anyone else frustrated by these issues, I have started another thread about it here: https://github.com/karma-runner/karma/issues/3445

JimLynchCodes avatar Mar 19 '20 04:03 JimLynchCodes