Files
sentinel/static/app/utils/testableTransition.tsx
2024-02-15 17:01:50 +00:00

31 lines
707 B
TypeScript

import type {Transition} from 'framer-motion';
import {IS_ACCEPTANCE_TEST, NODE_ENV} from 'sentry/constants';
/**
* Use with a framer-motion transition to disable the animation in testing
* environments.
*
* If your animation has no transition you can simply specify
*
* ```tsx
* Component.defaultProps = {
* transition: testableTransition(),
* }
* ```
*
* This function simply disables the animation `type`.
*/
const testableTransition =
!IS_ACCEPTANCE_TEST && NODE_ENV !== 'test'
? (t?: Transition) => t
: function (): Transition {
return {
delay: 0,
staggerChildren: 0,
type: false,
};
};
export default testableTransition;