Jeanluca Scaljeri
Jeanluca Scaljeri

Reputation: 29199

Debug a Karma unit test

I'm trying to debug my unit test. I'm using Karma (BTW, its an AngularJS project). I've manage to start the karma server, so when I start karma I get the page with the debugger button on the right top. When I click on it I get a white page. In the js console I see the following error

Uncaught TypeError: Object # has no method 'start' debug.html:35 window.karma.loaded debug.html:35 (anonymous function)

The weird thing is that inside debug.html there is no such thing as a start method :(

window.__karma__ = {
  info: function(info) {
    if (info.dump && window.console) window.console.log(info.dump);
  },
  complete: function() {},
  store: function() {},
  result: window.console ? function(result) {
    var msg = result.skipped ? 'SKIPPED' : (result.success ? 'SUCCESS ' : 'FAILED ');
    window.console.log(msg + result.suite.join(' ') + ' ' + result.description);

    for (var i = 0; i < result.log.length; i++) {
      window.console.error(result.log[i]);
    }
  } : function() {},
  loaded: function() {
    this.start();
  }
};

// All served files with the latest timestamps
window.__karma__.files = {

};

In the body of that file window.karma.loaded(); is called.

Any suggestions what might go wrong ?

Upvotes: 2

Views: 4663

Answers (1)

&#216;yvind Marthinsen
&#216;yvind Marthinsen

Reputation: 126

The problem is that window.__karma__.files is empty. Verify that your config file is correct and that you run it with karma start my.conf.js if it's not named karma.conf.js.

Upvotes: 3

Related Questions