# env.rb or spec_helper.rb
Capybara.register_driver :poltergeist do |app|
opts = {
extensions: ["#{Rails.root}/features/support/phantomjs/disable_animations.js"] # or wherever
}
Capybara::Poltergeist::Driver.new(app, opts)
end
Capybara.javascript_driver = :poltergeist
// disable_animations.js
var disableAnimationStyles = '-webkit-transition: none !important;' +
'-moz-transition: none !important;' +
'-ms-transition: none !important;' +
'-o-transition: none !important;' +
'transition: none !important;'
window.onload = function() {
var animationStyles = document.createElement('style');
animationStyles.type = 'text/css';
animationStyles.innerHTML = '* {' + disableAnimationStyles + '}';
document.head.appendChild(animationStyles);
};
As a followup, I found that triggering earlier in the loading cycle worked consistently: