You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"It has a long record of falling behind changes in React, preventing people from transitioning to newer React versions" In particular, Enzyme is still stuck on React 16; React 17 was released almost two years ago, and React 18 more recently. We use 16 now, but we may want to update.
"It relies on React internal implementation, and React team discourages using it". In particular:
I think it’s worth noting that if you can use a project like React Testing Library that doesn’t depend on React internals, it’s generally a good idea. At FB we’ve frozen Enzyme tests to stay on an old version of React that won’t be upgraded for this reason, and we banned using it in any new tests.
from Dan Abramov (redux creator; co-creator of create-react-app)
RTL tests resemble user interaction better (no shallow rendering; tests the DOM not components)
How to switch
Most of our frontend tests rely on a helper class, IntegrationTestHelper. In #1274 I wrote a new version of this (with almost identical API as the old) that uses RTL and Jest instead of Enzyme and Sinon, and re-wrote one test file as a proof of concept. So... Let's do that more.
The text was updated successfully, but these errors were encountered:
We should stop using Enzyme and use React Testing Library (RTL; @testing-library/react) instead.
Why ditch Enzyme / Why React Testing Library
There are lots of articles on this. I like Time to Say Goodbye—Enzyme.js. Here's a summary
"It has a long record of falling behind changes in React, preventing people from transitioning to newer React versions" In particular, Enzyme is still stuck on React 16; React 17 was released almost two years ago, and React 18 more recently. We use 16 now, but we may want to update.
"It relies on React internal implementation, and React team discourages using it". In particular:
from Dan Abramov (redux creator; co-creator of create-react-app)
RTL is officially recommended by React for testing for react.
RTL tests resemble user interaction better (no shallow rendering; tests the DOM not components)
How to switch
Most of our frontend tests rely on a helper class, IntegrationTestHelper. In #1274 I wrote a new version of this (with almost identical API as the old) that uses RTL and Jest instead of Enzyme and Sinon, and re-wrote one test file as a proof of concept. So... Let's do that more.
The text was updated successfully, but these errors were encountered: