开发者

SinonJS fake timer does not work with QUnit

开发者 https://www.devze.com 2023-03-24 01:55 出处:网络
I am running the following code with SinonJS and QUnit: var clock = this.sandbox.useFakeTimers(); var el = jQuery(\"<div></div>\");

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

精彩评论

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