茉莉花超时错误

3

我正在编写一个karma单元测试脚本,一切看起来很好,但是出现了错误:

Chrome 39.0.2171 (Windows 7) Unit: common.services.PartialUpdater Should be loaded with all dependencies FAILED
        Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Chrome 39.0.2171 (Windows 7): Executed 4 of 4 (1 FAILED) (5.025 secs / 5.006 secs)

函数在哪里被调用:

describe("Unit: common.services.PartialUpdater", function() {


      it("Should be loaded with all dependencies", function($rootScope) {                
          expect(true).toBe(true);
          jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
      });

      it("Should make a partial update when event is received", function() {
        expect(true).toBe(true);
        jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
      });

});

我不想增加jasme.default超时间隔,也不知道如何解决这个问题。有没有人遇到过这种问题并能提供一些经验?谢谢。
1个回答

1
你正在运行哪个版本的Jasmine?
在2.0中,测试中的第一个参数是异步回调函数,必须调用该函数才能注册完成。
尝试将你的测试更改为这样。
  it("Should be loaded with all dependencies", function(done) {                
      expect(true).toBe(true);
      // you probably don't need this any more.
      //jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
      done();
  });

或者从函数中删除done参数并使其同步。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接