Jasmine clock tick & Firefox: failing to trigger a Q.delay method

自古美人都是妖i 提交于 2019-12-22 20:02:52

问题


Lazy loading tests:

I am trying to build a test for Jasmine to test a method that uses Q.delay. To go around the 10 seconds wait i'm using Jasmine's clock:

jasmine.Clock.tick(10010);

This works on Chrome but does not work on Firefox. I saw that the delay method of Q utilized setTimeout so I can't see any reason for the different behaviors.

Any ideas why it fails on Firefox?


回答1:


With jasmine 2.0 and Q at the v1 tag, I'm able to run this spec:

describe("testing", function() {
  beforeEach(function() {
    jasmine.clock().install();
  });

  afterEach(function() {
    jasmine.clock().uninstall();
  });

  it("should work", function() {
    var foo = null;
    Q.delay('hi', 10000).then(function(arg) {
      foo = arg;
    });
    jasmine.clock().tick(10010);
    expect(foo).toEqual('hi');
  });
});

With no problems in both chrome, firefox, and phantomjs. I'm not sure if this is because we've fixed this issue in 2.0 or if you have some more complicated spec, that I'm not replicating here.



来源:https://stackoverflow.com/questions/18126604/jasmine-clock-tick-firefox-failing-to-trigger-a-q-delay-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!