Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lcov file misses line numbers. #20

Closed
MrHus opened this issue Jul 21, 2016 · 14 comments
Closed

lcov file misses line numbers. #20

MrHus opened this issue Jul 21, 2016 · 14 comments

Comments

@MrHus
Copy link

MrHus commented Jul 21, 2016

When the lcov file is generated it is missing line numbers.

This is what is generated:

TN:
SF:./src/app.js
FN:,(anonymous_1)
FN:,(anonymous_2)
FN:,(anonymous_3)
FNF:3
FNH:3
FNDA:7,(anonymous_1)
FNDA:7,(anonymous_2)
FNDA:7,(anonymous_3)
DA:11,1
DA:24,7
DA:27,7
DA:29,7
LF:4
LH:4
BRF:0
BRH:0
end_of_record

You can see FN:,(anonymous_1) which is false because it needs to have a line number before the comma, according to: http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php

My configuration is:

'use strict';

module.exports = function(config) {

  config.set({
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // base path, that will be used to resolve files and exclude
    basePath: '../',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'test/spec/**/*.js',
      'app/es6/**/*.js',
    ],

    // list of files / patterns to exclude
    exclude: [],

    // web server port
    port: 9002,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['PhantomJS'],

    // Which plugins to enable
    plugins: [
      'karma-phantomjs-launcher',
      'karma-jasmine',
      'karma-coverage',
      'karma-junit-reporter',
      'karma-babel-preprocessor',
      'karma-sourcemap-loader',
    ],

    // coverage reporter generates the coverage
    reporters: ['spec', 'coverage', 'junit'],

    preprocessors: {
      'app/**/*.js': ['babel', 'sourcemap'],
      'test/**/*.js': ['babel', 'sourcemap'],
    },
    babelPreprocessor: {
      options: {
        presets: ['es2015'],
        sourceMap: "inline",
        plugins: ['instanbul']
      }
    },
    // optionally, configure the reporter
    coverageReporter: {
      type: 'lcov',
      dir: 'coverage',
      subdir: 'report'
    }
  });
};

Did I misconfigure something, or did I stumble unto a bug?

@gotwarlost
Copy link
Contributor

I think you are somehow using istanbul v0.x for reporting even if you are using the babel plugin. Please make sure that all istanbul libs are the latest 1.x versions. This was a breaking change in the coverage format between v0 and v1

@MrHus
Copy link
Author

MrHus commented Jul 22, 2016

In my package.json I added: "istanbul": "1.1.0-alpha.1" just to be sure.

Now when I generate the lcov file I still get the same results.

@bcoe
Copy link
Member

bcoe commented Jul 24, 2016

@MrHus could you share an example of a failing project with us?

@MrHus
Copy link
Author

MrHus commented Jul 26, 2016

@bcoe I've done this you can see it here:

https://github.com/MrHus/wrong-code-coverage

@di2pojo
Copy link

di2pojo commented Sep 16, 2016

Hi, I'm having the same exact problem right now, did you manage to solve this issue?

@MrHus
Copy link
Author

MrHus commented Sep 16, 2016

@di2pojo No I never managed to solve the problem. I'm still hoping for a solution.

@matteoantoci
Copy link

Same problem here, it's giving me a lot of troubles integrating it with SonarQube, eg:

TN:
SF:./src/components/FormElements/utils/validator.js
FN:,(anonymous_0)
FN:,validateField
FN:,validateAllFields
FNF:3
FNH:3
FNDA:74,(anonymous_0)
FNDA:23,validateField
FNDA:2,validateAllFields
DA:5,74
DA:8,23
DA:12,2
DA:15,74
LF:4
LH:4
BRDA:,0,0,1
BRDA:,0,1,22
BRF:2
BRH:2
end_of_record

@Pipeman
Copy link

Pipeman commented Jan 13, 2017

We have exactly the same issue as reported by @matteoantoci. Were anyone able to solve the issue? I tried to bump to the latest version, but it didn't changed anything.

@ballwood
Copy link

ballwood commented Mar 10, 2017

This is potentially a problem with Karma coverage reporter, I ran into this issue at work the other day. Running tests using the mocha cli and then calling nyc generated a correct lcov report without missing line numbers.

@Chexpir
Copy link

Chexpir commented Mar 14, 2017

I'd like to keep using Karma coverage reporter. Interestingly, this defect is not open on the karma-coverage project.

I just took a look at the codebase of this plugin and it is pretty minimal, so I am unsure where the defect lies. Also taking a look on the instambul codebase I can't see how it might come from there.
Anyway, it's pretty annoying that after having all the set up working locally with ES6 you can't integrate it with your sonar systems.

Update: I've finally found where the defect lies. istanbuljs-archived-repos/istanbul-lib-instrument#14

I recommend to close this issue from this project.

@nowycondro
Copy link

It is fixed now. Try it.
istanbuljs/istanbuljs#8 (comment)

@Chexpir
Copy link

Chexpir commented Mar 21, 2017

thanks @nowycheung, but I cannot see the 4.1.0 release in the npm repository
Update I'm sorry. I saw there was a 4.1.0 release on package.json so I tried to use it. Using "next" version it works perfectly. thanks!!

@bcoe
Copy link
Member

bcoe commented Mar 21, 2017 via email

@bcoe
Copy link
Member

bcoe commented Jul 22, 2017

this should now be fixed \o/

@bcoe bcoe closed this as completed Jul 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants