Skip to content

Instantly share code, notes, and snippets.

@mark-rushakoff
Created March 2, 2012 16:44
Show Gist options
  • Save mark-rushakoff/1959568 to your computer and use it in GitHub Desktop.
Save mark-rushakoff/1959568 to your computer and use it in GitHub Desktop.
Make jasmine run at full speed when in a background tab
var foregroundScreenRefreshRate = 1500;
var backgroundScreenRefreshRate = 9000;
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate;
$(window).focus(function() {
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate;
});
$(window).blur(function() {
jasmine.getEnv().updateInterval = backgroundScreenRefreshRate;
});
@mark-rushakoff
Copy link
Author

Deleting the update interval actually caused the blur/focus event to never get called until specs were over. Oops!

A background timeout of 9000 was arbtitrarily chosen because the default max script limit in Firefox is 10 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment