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

TypeError: cannot read property 'split' of undefined #278

Open
akankshagaur opened this issue Jan 17, 2017 · 11 comments
Open

TypeError: cannot read property 'split' of undefined #278

akankshagaur opened this issue Jan 17, 2017 · 11 comments

Comments

@akankshagaur
Copy link

akankshagaur commented Jan 17, 2017

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 akankshagaur changed the title TypeError: cannot read property TypeError: cannot read property 'split' of undefined Jan 17, 2017
@chiefie
Copy link

chiefie commented Jan 20, 2017

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.

@franckXu
Copy link

franckXu commented Jan 23, 2017

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

@tommck
Copy link

tommck commented Mar 8, 2017

no updates?

@tommck
Copy link

tommck commented Mar 10, 2017

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

@sgen
Copy link

sgen commented Mar 16, 2017

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.

@tommck
Copy link

tommck commented Mar 17, 2017

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

@sgen
Copy link

sgen commented Mar 18, 2017

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.

@michaelBenin
Copy link

I believe there's a PR for this here: gotwarlost/istanbul#816

metatoaster added a commit to metatoaster/calmjs.webpack that referenced this issue Dec 8, 2017
- As the code need to be applied _inside_ the webpack, the relevant
  loader must be used.
- Using a fork of the loader because it can generate html reports
  without dying in a fire like the official one.

  - karma-runner/karma-coverage#123
  - karma-runner/karma-coverage#278
metatoaster added a commit to metatoaster/calmjs.webpack that referenced this issue Dec 14, 2017
- As the code need to be applied _inside_ the webpack, the relevant
  loader must be used.
- Using a fork of the loader because it can generate html reports
  without dying in a fire like the official one.

  - karma-runner/karma-coverage#123
  - karma-runner/karma-coverage#278
@jileeshs
Copy link

jileeshs commented May 23, 2018

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 gotwarlost/istanbul#816 (reference) @gotwarlost is not active.

@michaelBenin
Copy link

@jileeshs
Copy link

Thank you @michaelBenin

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

7 participants