Skip to content

Instantly share code, notes, and snippets.

@GlickG
Forked from cvan/commands.js
Created April 28, 2022 02:11
Show Gist options
  • Save GlickG/302b53a0c0892ff213d02329b1662a25 to your computer and use it in GitHub Desktop.
Save GlickG/302b53a0c0892ff213d02329b1662a25 to your computer and use it in GitHub Desktop.
cypress disable basic css transitions + animations
Cypress.Commands.add('cssDisableMotion', (selector = 'head') => {
cy.get('html').then(() => {
document.querySelector(selector).insertAdjacentHTML('beforeend', `
<style>
/* Disable CSS transitions. */
* { -webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; transition: none !important; }
/* Disable CSS animations. */
* { -webkit-animation: none !important; -moz-animation: none !important; -o-animation: none !important; animation: none !important; }
/* Reset values on non-opaque/offscreen framer-motion components. */
*[style*="opacity"] { opacity: 1 !important; }
*[style*="transform"] { transform: none !important; }
</style>
`);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment