question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

karma coverage does not show any data

See original GitHub issue

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”.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:53 (8 by maintainers)

github_iconTop GitHub Comments

17reactions
stsvilikcommented, Nov 14, 2016

I’ve had similar issue with browserify + babel + karma. Take a look here.

Key to my setup was to add [“istanbul”] into babel plugins.

5reactions
andy-dormancommented, Jun 17, 2015

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:

var istanbul = require("browserify-istanbul");

and set this config:

browserify: {
  transform: [
    [
      istanbul({
      ignore: ["node_modules/**", "**/*.spec.js"],
      includeUntested: false,
      defaultIgnore: true
      }),
      { global: true }
    ]
  ]
}

Not totally sure what this points to other than a possible issue with karma-browserify perhaps, but maybe it can help someone…

Read more comments on GitHub >

github_iconTop Results From Across the Web

karma coverage does not show any data
1 Answer 1 · Append the basepath to the preprocessor path: ../../app/js/**/*.js': ['coverage'] · Restart karma · View the updated report.
Read more >
Problem with karma-coverage
I have the last versions of Karma and karma-coverage and my problem is that when I run the tests with Karma in Windows...
Read more >
Find out how much code you're testing
Code coverage reports show you any parts of your code base that might not be properly tested by your unit tests. If you'd...
Read more >
Coverage - Karma test runner
This will create a coverage report for every browser that the tests are run in. In addition, it will create a JSON file...
Read more >
Coverage no longer works for karma-coverage : WEB-10292
Coverage no longer works for karma-coverage ... From user feedback: I followed the instructions to get the karma plugin installed and had coverage...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found