Skip to content

Instantly share code, notes, and snippets.

@paulnsorensen
Created June 6, 2014 16:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulnsorensen/8a31f5a7f9b58fb767fb to your computer and use it in GitHub Desktop.
Save paulnsorensen/8a31f5a7f9b58fb767fb to your computer and use it in GitHub Desktop.
Disabling CSS animations in tests
<%# http://www.venombytes.com/2013/03/11/faster-browser-specs %>
<% if Rails.env.test? -%>
<style type="text/css">
.notransition * {
/*CSS transitions*/
-webkit-transition: none !important;
-moz-transition: none !important;
-o-transition: none !important;
-ms-transition: none !important;
transition: none !important;
/*CSS transition properties*/
-webkit-transition-property: none !important;
-moz-transition-property: none !important;
-o-transition-property: none !important;
-ms-transition-property: none !important;
transition-property: none !important;
/*CSS transforms*/
-webkit-transform: none !important;
-moz-transform: none !important;
-o-transform: none !important;
-ms-transform: none !important;
transform: none !important;
/*CSS animations*/
-webkit-animation: none !important;
-moz-animation: none !important;
-o-animation: none !important;
-ms-animation: none !important;
animation: none !important;
}
</style>
<%= javascript_tag do %>
$.fx.off = true;
$($('body').addClass('notransition'));
<% end %>
<% end %>
<html>
<head>
<%= yield :head %>
</head>
<body>
<%= yield %>
<%= render partial: 'layouts/spec_performance' %>
</body>
</html>
@jcody
Copy link

jcody commented Sep 30, 2014

Digging this, but won't this only have an impact on view specs (i.e. cukes, capbara, etc)?

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