开发者

SinonJS fake timer does not work with QUnit

I am running the following code with SinonJS and QUnit:

var clock = this.sandbox.useFakeTimers();
var el = jQuery("<div></div>");
el.appendTo(document.b开发者_Go百科ody);

el.animate({ height: "200px", width: "200px" });
clock.tick(1000);

equals("200px", el.css("height"));
equals("200px", el.css("width"));

But the test fails, looks like jQuery is using the real clock and not the fake one.

I am using Chrome 12.0.742.122.

Any ideas?

Thank you


jQuery is using window.webkitRequestAnimationFrame or window.mozRequestAnimationFrame instead of setInterval.

If you set window.mozRequestAnimationFrame to false before loading jQuery, it will use setTimeout and SinonJS will work properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜