Created
August 26, 2011 21:06
-
-
Save fabiomcosta/1174444 to your computer and use it in GitHub Desktop.
Mocks the setTimeout function with jasmine, making setTimeout dependent tests synchronous and easier to test.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inside your beforeEach hook | |
spyOn(window, 'setTimeout').andCallFake(function(fn){ | |
fn.apply(null, [].slice.call(arguments, 2)); | |
return +new Date; | |
}); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment