axvo
axvo

Reputation: 839

Karma-coverage : Object has no method isIdentifierPart

I want to use Karma for code coverage on my JQuery Mobile project and QUnit or Jasmine for tests.
I have installed all the node packages I need (karma, karma-cli, karma-coverage, jasmine/qunitjs, karma-chrome-launcher) and created the following karma.conf file :

karma.conf.js

// Karma configuration
module.exports = function(config) {
config.set({
    basePath: '',
    frameworks: ['jasmine'],
    files: [
        'absence.js',
        'absence.test.js'
    ],
    exclude: [
    ],
    preprocessors: {
     'absence.js': ['coverage']
    },
    reporters: ['progress', 'coverage'],
    coverageReporter: {
        type : 'html',
        dir: 'coverage/'
    },
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}

and this test file (with Jasmine) :

absence.test.js

describe("A suite", function() {
  it("contains spec with an expectation", function() {
    expect(true).toBe(true);
  });
});

I launch a karma start on my project, my absence.js file contains only this function :

function test() {
    var foo = 'bar';
}

and it works fine, my coverage report is generated and indicates 50% of code covered in my absence.js file.

But if I modify my function using a "if" statement :

function test() {
    if (1 == 1){
       var foo = "bar";
    }
}

I have the following error in the console :

ERROR [preprocessor.coverage]: Object [object Object] has no method 'isIdentifierPart'

Actually, if I use any conditionnal statement or a loop, I got this error. Is there something wrong with my karma configuration ?

EDIT

I reinstalled Node.js and all the karma packages and it finally works but now I have a strange issue : all the generated html files get placed in my source directory, evn if I specified a coverageReporter dir...
Any idea ?

Upvotes: 0

Views: 85

Answers (1)

axvo
axvo

Reputation: 839

Using a previous version of karma-coverage package, I don't have the issue anymore. I have uninstalled the latest version (0.5.0) and installed the 0.2.7.

Upvotes: 0

Related Questions