茉莉花钟嘀嗒& Firefox:无法触发Q.delay方法 [英] Jasmine clock tick & Firefox: failing to trigger a Q.delay method

查看:131
本文介绍了茉莉花钟嘀嗒& Firefox:无法触发Q.delay方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

延迟加载测试:

我正在尝试为Jasmine构建测试以测试使用 Q.delay
要花10秒钟等待我使用Jasmine的时钟

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);

这适用于Chrome,但不适用于Firefox。我看到Q的延迟方法使用 setTimeout ,所以我看不出任何不同行为的原因。

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.

为什么它在Firefox上失败了?

Any ideas why it fails on Firefox?

推荐答案

用茉莉花2.0和Q在 v1标签,我能够运行这个spec:

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');
  });
});

chrome,firefox和phantomjs都没有问题。我不确定这是不是因为我们已经在2.0中解决了这个问题,或者如果你有一些更复杂的规范,我不会在这里复制。

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.

这篇关于茉莉花钟嘀嗒& Firefox:无法触发Q.delay方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆