Migrate away from Enzyme tests in favor of React Testing Library #166
Labels
epic
Large unit of work, consisting of multiple tasks
maintenance
Routine upkeep necessary for the health of the platform
We recently noticed during our attempt to ensure Paragon is compatible with React 18 that using Enzyme with this React version for JavaScript tests will not be compatible, as Enzyme is largely no longer maintained. See https://dev.to/wojtekmaj/enzyme-is-dead-now-what-ekl for additional context, but the short of it is:
The recommended alternative to Enzyme is React Testing Library. Migrating between these test frameworks will not be as trivial as drop-in replacements; the mindsets in using Enzyme vs. React Testing Library are different: with Enzyme, you can (and sometimes have to) rely on implementation details of what you're testing whereas with React Testing Library, you're encouraged more to think about testing from a user's perspective (e.g., is there an element with this matching {text | a11y
role
|data-testid
| etc) rendered. From there, you can access the underlying DOM node to make further assertions about class names, etc. if needed.Related, there is a proposal to officially deprecate Enzyme through Open edX and amend the OEP-11 that recommends the use of Enzyme to suggest the use of React Testing Library instead: openedx/open-edx-proposals#487
The text was updated successfully, but these errors were encountered: