Skip to content

Instantly share code, notes, and snippets.

@mrclay
Created January 19, 2015 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrclay/1accd8834fd78c371f2b to your computer and use it in GitHub Desktop.
Save mrclay/1accd8834fd78c371f2b to your computer and use it in GitHub Desktop.
Jasmine helper to cleanup tests that have async operations without a callback.
/**
* Jasmine helper: Call func sequentially after blocking for {delay} milliseconds
*
* @param {Number} delay
* @param {Function} func
*
* @link http://jasmine.github.io/1.3/introduction.html#section-Asynchronous_Support
*/
function runsAfter(delay, func) {
var blocking = true;
runs(function () {
setTimeout(function () {
blocking = false;
}, delay);
});
waitsFor(delay * 2, function () {
return !blocking;
});
runs(func);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment