karma-coverage: Karma coverage does not show any data when using webpack + ES6

Hi

My config

module.exports = function(config) {
  config.set({
    browsers: ["ChromeCanary"],
    coverageReporter: {
      type: "html",
      dir : "./docs/js-coverage"
    },
    files: [{
        pattern: "test.bundle.js",
        watched: false
      }],
    frameworks: ["jasmine"],
    preprocessors: {
        "src/main/webapp/**/*.js": "coverage",
        "test.bundle.js": ["webpack"]
    },
    reporters: ["coverage", "dots"],
    singleRun: false,
    webpack: {
        module: {
            loaders: [{
                  test: /\.js/,
                  exclude: /node_modules/,
                  loader: "babel-loader?cacheDirectory&optional[]=runtime"
                }]
        },
        watch: true
    },
    webpackServer: {
        noInfo: true
    }
  });
};

test.bundle.js

var context = require.context("./src/main/webapp", true, /.+\.test\.js$/);
context.keys().forEach(context);

Tests run fine, HTML report is generated, but it contains no files in the list.

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 10
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Was not able to get coverage information with webpack (2) and karma-coverage. Had to use both “istanbul-instrumenter-loader” as a webpack file loader for test run and “karma-coverage-istanbul-reporter” as coverage reporter and after couple of days of struggles it worked.

coverage sourcemap not work. only index.js. image image

no filelists, can you help me?

I have the same problem. I thought I did something wrong, but whatever I try, it just comes up with zero files in the generated HTML. Is this a bug?

Edit: I fixed this by adding isparta preloaders to the webpack.module:

preLoaders: [
  { test: /\.js|jsx$/, exclude: /(src|node_modules)/, loaders: ['babel'] },
  { test: /\.js|jsx$/, include: /(src)/, loaders: ['isparta'] }
],

Hi, I found an alternative. Use Isparta loader in your karma conf file.

preLoaders: [
   {
        test: /^((?!spec).)*\.js$/,
        include: path.resolve('src/'),
        loader: 'isparta'
   }
],

Don’t forget to require karma-coverage and add it in preprocessors.

I hope it will help you.