Enzyme is dead. (There will be no React 18 support)
you can read the article below for more info but in short:
the API changes in React 18 meant that releasing a React 18 Enzyme adapter will not be possible
A bit of personal advice
While Migrate from Enzyme support article is available, I suggest you to just start fresh, forgetting that Enzyme has ever existed. RTL is by no means an Enzyme drop-in replacement, so having a completely fresh mindset will help you getting the most of it.
What should I do?
The answer is, as always, it depends. You don't have to upgrade React, after all.
Here's what I would do:
- Start familiarizing yourself with React Testing Library(RTL), an officially recommended library for React components.
- Make a rule to write new tests using RTL only.
- Consider making a rule to rewrite tests to RTL whenever you need to touch them and/or the component they are testing.
- In your designated time for repaying technical debt (you have designated time for repaying technical debt, right? …right?), rewrite your remaining Enzyme-based tests to RTL.
- Clean up your repo from Enzyme-specific bits
- When you're ready, upgrade to React 18.
Link of complete article by Wojciech Maj, maintainer of @wojtekmaj/enzyme-adapter-react-17, React-PDF, React-Calendar, and React-Date-Picker:
https://dev.to/wojtekmaj/enzyme-is-dead-now-what-ekl
render
from react testing library. It gives me theWarning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17
warning / error, but the tests still pass. Its not ideal, but it works for now while the community scrambles to catch up with react 18 – Giannini