【问题标题】:Jasmine + Karma: 'expect' was used when there was no current spec error, but why?Jasmine + Karma:在没有当前规范错误时使用“expect”,但为什么呢?
【发布时间】:2016-08-05 17:26:17
【问题描述】:

我完全迷路了。当我在 Karma 中运行这个用 Jasmine 编写的测试套件时,我得到了这个错误:'expect' was used when there is no current spec,这可能是因为异步测试超时

但是为什么呢?这是一个完全同步的例子。

describe('Controllers Autocomplete', () => {
  it('should inject the empty suggestions container', () => {
    let a = 1;
    let b = 2;
    expect(a).toNotEqual(b);
  });
}); 

【问题讨论】:

    标签: javascript node.js jasmine karma-runner


    【解决方案1】:

    终于解决了!

    伙计们,永远不要这样做...... Karma.config.js 文件:

    config.set({
        // 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: ['**mocha**', 'jasmine-jquery', '**jasmine**', 'browserify'],
    

    Mocha 和 Jasmine 都是测试框架,它们的语法非常相似。所以我以为我在使用 Jasmine,但实际上是在使用 Mocha……只要坚持一个。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      • 1970-01-01
      • 2012-11-13
      相关资源
      最近更新 更多