public
Last active

Make jasmine run at full speed when in a background tab

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12
var foregroundScreenRefreshRate = 1500;
var backgroundScreenRefreshRate = 9000;
 
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate;
 
$(window).focus(function() {
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate;
});
 
$(window).blur(function() {
jasmine.getEnv().updateInterval = backgroundScreenRefreshRate;
});

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.