Skip to content

e2e tests: framer-motion animations are not disabled by plugin disabling CSS animations #43282

Open
@ciampo

Description

What

The disable-animation plugin runs during e2e tests in order to make them "more stable" (see original PR).

But this set of styles don't have an impact on animations happening via the framer-motion library (as noted by @talldan in #43186 (review)) — this is because framer-motion "manually" sets the animated values as inline styles for each frame (instead of relying on native CSS animations and transforms).

Proposed next steps

The best solution that comes to my mind is:

  • add a script to the disable-animation plugin, setting a global variable that can be read in app code
  • add the MotionConfig component (see docs): when the global variable from the point before is defined, the reducedMotion option can be set to always, while normally it would be set to user

It should be noted that this is only a suboptimal solution:

  • From the docs: "When motion is reduced, transform and layout animations will be disabled. Other animations, like opacity and backgroundColor, will persist." — so this wouldn't fix entirely the issue (disabling all transitions/animations)
  • this is not great, since our tests wouldn't be running the same code that our user see

An alternative approach could be to manually check for that global "e2e_disable_css_animations" variable in the React code, and conditionally render an alternative to framer-motion components that doesn't animate (i.e. a normal div instead of a motion.div) — although this approach would also mean that our e2e tests would not actually test the same exact components that are rendered in our user's browsers

Activity

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

Metadata

Assignees

No one assigned

    Labels

    [Package] E2E Tests/packages/e2e-tests[Type] Automated TestingTesting infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions