【问题标题】:Debug a Karma unit test调试 Karma 单元测试
【发布时间】:2013-09-18 10:52:00
【问题描述】:

我正在尝试调试我的单元测试。我正在使用 Karma(顺便说一句,它是一个 AngularJS 项目)。 我已经成功启动了 karma 服务器,所以当我启动 karma 时,我会看到右上角带有调试器按钮的页面。当我点击它时,我得到一个白页。在 js 控制台中我看到以下错误

Uncaught TypeError: Object # has no method 'start' debug.html:35 window.业力.loaded debug.html:35 (匿名函数)

奇怪的是,在 debug.html 里面没有 start 方法这样的东西:(

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 = {

};

在该文件窗口的正文中。karma.loaded();叫做。

有什么可能出错的建议吗?

【问题讨论】:

    标签: javascript unit-testing debugging karma-runner


    【解决方案1】:

    问题是window.__karma__.files 是空的。验证您的配置文件是否正确,如果它不是名为 karma.conf.js,则使用 karma start my.conf.js 运行它。

    【讨论】:

    • 命令现在看起来像这样: karma start //karma.conf.js --no-single-run --auto-watch --reporters dots -- log-level debug
    • 我在配置文件中发现了问题,thnx!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    • 2017-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 2021-07-10
    相关资源
    最近更新 更多