Jasmine environments have a default updateInterval value of 250 that determines how often, in milliseconds, execution of the next spec will be deferred so that the screen can be updated.
var now = new Date().getTime();
if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
self.env.lastUpdate = now;
self.env.setTimeout(function() {
self.next_();
}, 0);
} else {
if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
goAgain = true;
} else {
self.next_();
}
}
Both Chrome and Firefox now require a minimum value of one second for setTimeout in a background tab. This basically means that for every 250ms of work that we do, we end up sleeping for 1000ms.
This gist shows one way to tell Jasmine to not even bother trying to update the screen when running in the background.
var foregroundScreenRefreshRate = 1500;
var backgroundScreenRefreshRate = 9000;
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate;
$(window).focus(function() {
jasmine.getEnv().updateInterval = foregroundScreenRefreshRate;
});
$(window).blur(function() {
jasmine.getEnv().updateInterval = backgroundScreenRefreshRate;
});
(Please refer to the gist for the most up-to-date code.)
This code makes Jasmine run at full-speed in a background tab in Chrome, but continue to be updated about once every 2.5 seconds when in a foreground tab. However, using this as-is in Firefox will result in a warning about an unresponsive script, if the tab is inactive. Luckily, you can continue to run Firefox in the foreground fine with this script (good for CI perhaps), or you can just override the dom.max_script_run_time variable to never get that warning, or you can set updateInterval to something less than the default 10 second max script run time.
Do your Jasmine tests (or anything else) seem to lock up when they aren't the active tab in your browser?
Unfortunately, your new and modern browser is to blame. There are a few workarounds, but none of them are ideal in my opinion.
Ask for Help
"mp4s do not play during download in chrome"
Talks at Pivotal are recorded and published in various formats. Our talks page has an embedded viewer so that people can watch the video without downloading. We also offer a downloadable version in mp4. Most browsers will play the video as it is downloading. Google Chrome does not. Are we doing something wrong?

Interesting Things
Beware: has_many associated objects are saved before has_one associated objects.
update_attribute of foreign_key value on belongs_to association does not save...when object was created by factory girl?
This is pretty specific, but perhaps not enough to be useful. The team tried to do an update_attribute on an object generated by factory girl, changing the belongs_to column value. However, no database update would occur. They later resolved this by doing a reload on the object before the update_attribute.
"Update_attribute is almost never the right thing to do" --anon
