Skip to content

Instantly share code, notes, and snippets.

@fabiomcosta
Created August 26, 2011 21:06
Show Gist options
  • Save fabiomcosta/1174444 to your computer and use it in GitHub Desktop.
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.
// 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