问题
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