testableTransition.tsx 651 B

1234567891011121314151617181920212223242526272829
  1. import {Transition} from 'framer-motion';
  2. import {IS_ACCEPTANCE_TEST} from 'sentry/constants';
  3. /**
  4. * Use with a framer-motion transition to disable the animation in testing
  5. * environments.
  6. *
  7. * If your animation has no transition you can simply specify
  8. *
  9. * ```tsx
  10. * Component.defaultProps = {
  11. * transition: testableTransition(),
  12. * }
  13. * ```
  14. *
  15. * This function simply disables the animation `type`.
  16. */
  17. const testableTransition = !IS_ACCEPTANCE_TEST
  18. ? (t?: Transition) => t
  19. : function (): Transition {
  20. return {
  21. delay: 0,
  22. staggerChildren: 0,
  23. type: false,
  24. };
  25. };
  26. export default testableTransition;