testableTransition.tsx 702 B

123456789101112131415161718192021222324252627282930
  1. import {Transition} from 'framer-motion';
  2. import {IS_ACCEPTANCE_TEST, NODE_ENV} 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 =
  18. !IS_ACCEPTANCE_TEST && NODE_ENV !== 'test'
  19. ? (t?: Transition) => t
  20. : function (): Transition {
  21. return {
  22. delay: 0,
  23. staggerChildren: 0,
  24. type: false,
  25. };
  26. };
  27. export default testableTransition;