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.

TypeError: cannot read property 'split' of undefined

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:8
  • Comments:11

github_iconTop GitHub Comments

3reactions
sgencommented, 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.

0reactions
jileeshscommented, May 24, 2018

Thank you @michaelBenin

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent cannot read property split of undefined
This error is a TypeError , and it occurs when calling a method, operand, or argument on the wrong data type, or when...
Read more >
How to Prevent cannot read property split of ... - Gopi Gorantala
The "cannot read property 'split' of undefined" error occurs when trying to call split() method on a variable that stores an undefined value....
Read more >
Cannot Read Property 'split' of Undefined - freeCodeCamp
it will throw the TypeError: Cannot read property 'split' of undefined error. The split method. When split is called on a string, it...
Read more >
Uncaught TypeError: Cannot read property 'split' of undefined
Your question answers itself ;) If og_date contains the date, it's probably a string, so og_date.value is undefined.
Read more >
TypeError: Cannot read property 'split' of undefined - SitePoint
TypeError : Cannot read property 'split' of undefined ... Somebody please guide me. Zulfi. Zulf. ... If you want contractCode2 to be a...
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