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

TypeError: cannot read property 'split' of undefined

Open akankshagaur opened this issue 8 years ago • 11 comments

Hi,

version: 1.1.1

I am using Karma-coverage to generate lcov report with in-memory report like this:

coverageReporter: {
      dir: 'reports/',
      reporters: [
         { type: 'in-memory' },
         { type: 'lcov', subdir: 'report-lcov' },
      ]
   },

I am getting the error:

TypeError: Cannot read property 'split' of undefined
    at HtmlReport.writeDetailPage ({path}\node_modules\istanbul\lib\report\html.js:412:28)

I tried modifying the html.js to see the result. coverage is sending undefined value to istanbul in the end. My reports are generating properly, but this error fails my build. Is there a fix to it?

akankshagaur avatar Jan 17 '17 06:01 akankshagaur

I am having this same issue too.

I'm using fountainjs to generate webapp, using Angular 1 with bower dependencies and injection, configured it to do coverage, ran the test and it passed the test and when generating the report, it failed with this error. However, the output gets generated.

chiefie avatar Jan 20 '17 08:01 chiefie

maybe this answer will help you ,istanbul-instrumenter-loader / html reports fail w/ v1 #32

franckXu avatar Jan 23 '17 13:01 franckXu

no updates?

tommck avatar Mar 08 '17 18:03 tommck

I've been trying to figure out this problem for a couple of days myself. Please let me know if you figure anything out

tommck avatar Mar 10 '17 14:03 tommck

Ive been doing some debugging and I suspect the root cause is config.files is being passed to istanbul despite config.preProcessors patterns being set to instrument only some files.

This is the config for the project Im working on:

  config.set({
    frameworks: ["browserify", "jasmine"],
    files: [
       "helpers.js",
       "helpers.test.js",
    ],
    preprocessors: {
      'helpers.js': ['coverage', 'browserify'],
      'helpers.test.js': ['browserify']
    },
    reporters: ["progress", 'coverage'],
    browsers: ["Chrome"],
    client: {
      captureConsole: true,
    },
    logLevel: config.LOG_DEBUG,
    browserify: {
      debug: true,
      transform: ['browserify-istanbul']
    }
  });
};

Despite the preProcessor being set to only instrument helpers.js both helpers.js and helpers.test.js are being reported on.

The failure results from coverage report for helpers.test.js not containing the .code property, causing istanbul to check its file store for the contents of helpers.test.js via karma's MemoryStore here. Apparently MemoryStore does not contain the source code thus causing the value of code to be undefined here.

I am not well versed in the internals of karma or karma-coverage but I will keep looking later today.

sgen avatar Mar 16 '17 15:03 sgen

I think you're on the right track. I really wish someone could solve this. I haven't had any luck.

tommck avatar Mar 17 '17 19:03 tommck

I haven't made much progress. Ive tracked the bug to here the result parameter contains the invalid coverage property. However I cannot find the source of it. The only place I can find Karma.complete() being called is here however this only occurs on an error and no arguments are passed.

If someone knows where this event is being emitted from let me know.

sgen avatar Mar 18 '17 17:03 sgen

I believe there's a PR for this here: https://github.com/gotwarlost/istanbul/pull/816

michaelBenin avatar Jun 27 '17 15:06 michaelBenin

Looks like Istanbul is not being maintained. I saw a sad comment on one of the PRs related to this issue, according to last comment on this https://github.com/gotwarlost/istanbul/pull/816#ref-commit-4a5e92c @gotwarlost is not active.

jileeshs avatar May 23 '18 21:05 jileeshs

@jileeshs https://github.com/istanbuljs/istanbuljs

michaelBenin avatar May 23 '18 21:05 michaelBenin

Thank you @michaelBenin

jileeshs avatar May 24 '18 15:05 jileeshs