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.

ERROR [coverage]: [TypeError: Cannot call method 'split' of undefined]

See original GitHub issue

I’m getting this error lately. Here is the full stack trace:

PhantomJS 1.9.8 (Linux): Executed 493 of 494 (skipped 1) SUCCESS (1.667 secs / 0.949 secs)

ERROR [coverage]: [TypeError: Cannot call method 'split' of undefined]
TypeError: Cannot call method 'split' of undefined
  at HtmlReport.Report.mix.writeDetailPage (/home/foo/projects/replatform/httpd/node_modules/istanbul/lib/report/html.js:379:31)
  at /home/foo/projects/replatform/httpd/node_modules/istanbul/lib/report/html.js:456:26
  at SyncFileWriter.extend.writeFile (/home/foo/projects/replatform/httpd/node_modules/istanbul/lib/util/file-writer.js:57:9)
  at FileWriter.extend.writeFile (/home/foo/projects/replatform/httpd/node_modules/istanbul/lib/util/file-writer.js:124:23)
  at /home/foo/projects/replatform/httpd/node_modules/istanbul/lib/report/html.js:455:24
  at Array.forEach (native)
  at HtmlReport.Report.mix.writeFiles (/home/foo/projects/replatform/httpd/node_modules/istanbul/lib/report/html.js:449:23)
  at /home/foo/projects/replatform/httpd/node_modules/istanbul/lib/report/html.js:451:22
  at Array.forEach (native)
  at HtmlReport.Report.mix.writeFiles (/home/foo/projects/replatform/httpd/node_modules/istanbul/lib/report/html.js:449:23)
  at HtmlReport.Report.mix.writeReport (/home/foo/projects/replatform/httpd/node_modules/istanbul/lib/report/html.js:533:14)
  at /home/foo/projects/replatform/httpd/node_modules/karma-coverage/lib/reporter.js:138:24
  at /home/foo/projects/replatform/httpd/node_modules/karma/lib/helper.js:87:7
  at Object.oncomplete (fs.js:107:15)


Here are my dependencies:

  "devDependencies": {
    "angular-cookies": "^1.3.5",
    "bootstrap": "^3.3.0",
    "brfs": "^1.2.0",
    "browser-sync": "^1.6.3",
    "browserify": "^6.2.0",
    "browserify-istanbul": "^0.1.2",
    "browserify-shim": "^3.8.0",
    "chai": "^1.9.2",
    "chalk": "^0.5.1",
    "console-shim2": "0.1.0",
    "csswring": "^1.3.1",
    "del": "^0.1.3",
    "event-stream": "^3.1.7",
    "exorcist": "^0.1.6",
    "fastclick": "^1.0.3",
    "glob": "^4.0.6",
    "gulp": "^3.8.9",
    "gulp-changed": "^1.0.0",
    "gulp-concat": "^2.4.1",
    "gulp-flatten": "0.0.4",
    "gulp-iconfont": "^0.2.1",
    "gulp-if": "^1.2.5",
    "gulp-insert": "^0.4.0",
    "gulp-jasmine": "^1.0.1",
    "gulp-jscs": "^1.2.1",
    "gulp-jshint": "^1.9.0",
    "gulp-karma": "0.0.4",
    "gulp-less": "^1.3.6",
    "gulp-load-plugins": "^0.7.1",
    "gulp-ng-annotate": "^0.3.3",
    "gulp-notify": "^2.0.0",
    "gulp-postcss": "^2.0.0",
    "gulp-rename": "^1.2.0",
    "gulp-replace": "^0.5.0",
    "gulp-sourcemaps": "^1.2.7",
    "gulp-uglify": "^1.0.1",
    "gulp-util": "^3.0.1",
    "istanbul": "0.2.6",
    "jshint-stylish": "^1.0.0",
    "karma": "~0.12.0",
    "karma-bro": "^0.9.0",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "~0.1.3",
    "karma-coverage": "~0.2.6",
    "karma-firefox-launcher": "~0.1",
    "karma-html2js-preprocessor": "~0.1",
    "karma-jasmine": "~0.2.0",
    "karma-junit-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "~0.1.4",
    "karma-sinon": "^1.0.3",
    "karma-spec-reporter": "0.0.12",
    "merge-stream": "^0.1.6",
    "napa": "^1.0.2",
    "ng-storage": "^0.3.1",
    "path": "^0.4.9",
    "pretty-hrtime": "^0.2.2",
    "proxyquireify": "^1.1.0",
    "require-dir": "^0.1.0",
    "run-sequence": "^1.0.1",
    "sax": "^0.6.1",
    "sinon": "^1.10.3",
    "sinon-chai": "^2.6.0",
    "streamqueue": "^0.1.1",
    "vinyl-buffer": "^1.0.0",
    "vinyl-source-stream": "^1.0.0",
    "vinyl-transform": "0.0.1",
    "watchify": "^2.1.1"
  }

I’ve tried using the latest version of istanbul but that doesn’t help any. Is there any more info I can provode to help troubleshoot this?

Here’s my karma.conf.js file:

// Karma configuration
// Generated on Fri Oct 17 2014 15:46:09 GMT-0700 (PDT)

module.exports = function(config) {
  var options = {
    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',
    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['chai', 'sinon', 'jasmine', 'browserify'],
    // list of files / patterns to load in the browser
    files: [
      'node_modules/angular/angular.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'src/test/chai-sinon-setup.js',
      'src/test/**/*.js'
    ],
    // list of files to exclude
    exclude: [
    ],
    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'src/main/**/*.js': ['browserify', 'coverage'],
      'src/test/**/*.js': ['browserify']
    },
    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec', 'coverage'],
    coverageReporter: {
      reporters: [
        {type: 'html', dir: 'coverage/'},
        {type: 'cobertura'}
      ]
    },
    // web server port
    port: 9876,
    // enable / disable colors in the output (reporters and logs)
    colors: true,
    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,
    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: [
      //'Chrome'
      'PhantomJS'
    ],
    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,
    // Browserify config (all optional)
    browserify: {
      // extensions: ['.coffee'],
      // ignore: [],
      plugin: ['proxyquireify/plugin'],
      transform: ['brfs', 'browserify-istanbul'],
      debug: false
      // noParse: ['jquery'],
      //watch: true,
    },
    plugins: [
      // Karma will require() these plugins
      'karma-bro',
      'karma-chai',
      'karma-spec-reporter',
      'karma-sinon',
      'karma-chrome-launcher',
      'karma-phantomjs-launcher',
      'karma-firefox-launcher',
      'karma-jasmine',
      'karma-coverage'
    ]
  };

  if (process.env.KARMA_BROWSER_NO_ACTIVITY_TIMEOUT) {
    options.browserNoActivityTimeout =  process.env.KARMA_BROWSER_NO_ACTIVITY_TIMEOUT;
  }

  config.set(options);
};

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:32 (5 by maintainers)

github_iconTop GitHub Comments

21reactions
johnnyreillycommented, Jul 28, 2015

Hi,

I can see this has been closed as fixed but the issue still seems to exist.

28 07 2015 15:19:13.438:ERROR [coverage]: [TypeError: Cannot read property 'split' of undefined]
TypeError: Cannot read property 'split' of undefined
    at HtmlReport.Report.mix.writeDetailPage (E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\reort\html.js:407:30)
    at E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\report\html.js:484:26
    at SyncFileWriter.extend.writeFile (E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\util\fil-writer.js:57:9)
    at FileWriter.extend.writeFile (E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\util\file-writer.js:147:23)
    at E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\report\html.js:483:24
    at Array.forEach (native)
    at HtmlReport.Report.mix.writeFiles (E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\report\tml.js:477:23)
    at E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\report\html.js:479:22
    at Array.forEach (native)
    at HtmlReport.Report.mix.writeFiles (E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\report\tml.js:477:23)
    at HtmlReport.Report.mix.writeReport (E:\Source\PROJECT\node_modules\karma-coverage\node_modules\istanbul\lib\reporthtml.js:561:14)
    at writeReport (E:\Source\PROJECT\node_modules\karma-coverage\lib\reporter.js:62:16)
    at E:\Source\PROJECT\node_modules\karma-coverage\lib\reporter.js:286:11
    at FSReqWrap.oncomplete (fs.js:95:15)

These are my devDependencies:

  "devDependencies": {
    "babelify": "^6.1.2",
    "browserify": "^10.2.4",
    "browserify-istanbul": "^0.2.1",
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^2.3.1",
    "gulp-cached": "^1.1.0",
    "gulp-cssmin": "^0.1.7",
    "gulp-if": "^1.2.5",
    "gulp-less": "^3.0.3",
    "gulp-notify": "^2.2.0",
    "gulp-sourcemaps": "^1.5.2",
    "gulp-streamify": "0.0.5",
    "gulp-uglify": "^1.2.0",
    "gulp-util": "^3.0.6",
    "jasmine-core": "^2.3.4",
    "karma": "^0.13.2",
    "karma-browserify": "^4.2.1",
    "karma-coverage": "^0.4.2",
    "karma-jasmine": "^0.3.6",
    "karma-mocha-reporter": "^1.0.2",
    "karma-phantomjs-launcher": "^0.2.0",
    "karma-phantomjs-shim": "^1.0.0",
    "karma-teamcity-reporter": "^0.2.0",
    "phantomjs": "^1.9.17",
    "vinyl-source-stream": "^1.1.0",
    "watchify": "^3.2.3"
  },

And this is my config:

module.exports = function(config) {
  config.set({
    browsers: [ 'PhantomJS' ],

    files: [
      //'src/**/!(main).js',
      'src/dependencies.js',
      'test/**/*.tests.js'
    ],

    frameworks: [ 'jasmine', 'browserify', 'phantomjs-shim' ],

    logLevel: config.LOG_INFO, //config.LOG_DEBUG

    preprocessors: {
      'src/**/*.js': [ 'browserify', 'coverage' ],
      'test/**/*.tests.js': [ 'browserify' ]
    },

    // browserify configuration
    browserify: {
      debug: true,
      transform: [
        ['babelify', { sourceMaps: false, stage: 3 }],
        'browserify-istanbul'
      ]
    },

    coverageReporter: {
      reporters:[
        {type: 'html', dir:'coverage/'},
        //{type: 'teamcity'},
        {type: 'text'},
        {type: 'text-summary'}
      ],
    }
  });
};

I’m on Windows in case that’s relevant… Locking the dependency for karma-coverage to 0.2.6 did not work for me unfortunately.

1reaction
Tin-Nguyencommented, Jul 8, 2015

Yes, sorry for my mistake. I did it. However, the issue still be there.

I tried to do with logLevel: config.LOG_DISABLE in karma.conf.js file. The workaround works for me. But I’m not sure this is a good way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot call method "split" of undefined
I was calling my function from a cell in a google spreadsheet document like this "=myFunction(A1:A)" the problem was that, since there were...
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 >
Untitled
新建一个ts声明文件如:images. error: TypeError: Cannot read properties of undefined (readingIn this Angular tutorial, We are going to see how does Change ...
Read more >
How to Prevent cannot read property split of undefined
The "cannot read property split of undefined" error occurs when we try to call the split() method on a variable that stores an...
Read more >
Unconfirmed Errata - O'Reilly Media
The errata list is a list of errors and their corrections that were found after ... AssertionError: "TypeError: Cannot call method 'split' of...
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