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 empty with a simple sample

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:9
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
njleonzhangcommented, Jul 6, 2018

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.

0reactions
JimLynchCodescommented, Mar 19, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Karma coverage always coming empty - Stack Overflow
So I solved it in the following HARD but VERY SIMPLE way: Create a new folder, or delete all the content of the...
Read more >
karma-coverage - npm
A Karma plugin. Generate code coverage.. Latest version: 2.2.0, last published: a year ago. Start using karma-coverage in your project by ...
Read more >
Karma coverage using Instabul - Medium
In this post I am going to create some simple tests, run them on Karma using Jasmine and finally, show some code coverage...
Read more >
Coverage - Karma test runner
For example if all your code lives in lib/ you need to add this to your configuration file. preprocessors = { '**/lib/*.js': 'coverage'...
Read more >
Front-End Unit Testing Using Karma Test Runner
This tutorial explains how to setup Karma & automate Front-End Unit Testing ... For example, to publish code test coverage to coveralls.io; ...
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