Turn off animations in Capybara tests
You can try to create some transition reset and apply it on a specific element.
.reset-transition {
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;
}
You can also apply it to ALL and place this css after Bootstrap
* {
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;
}
You can make it more specific
div, a, span, footer, header {
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;
}
# 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);
};
or only time
var disableAnimationStyles = '-webkit-transition-duration: .0s !important;' +
'-o-transition-duration: .0s !important;' +
'transition-duration: .0s !important;';
Starting from Capybara v3.2.0:
Capybara.disable_animation = true