Does Enzyme support React version 18?

Viewed 8034

Recently, React 18 has released and I have upgraded my project to 18. I noticed that all of my unit tests that were written by Jest and Enzyme are failing. I have used mount from Enzyme as a wrapper of my component and noticed the following error:

TypeError: Cannot read property 'child' of undefined

I also tried to check if it has support for React 18 yet but couldn't find any suitable link about that.

Does anybody have any thoughts about that? Or are there any workarounds that can be followed in that case?

3 Answers

React 18 was released in March 2022. Enzyme's last commit is from September 2021. It seems fair to assume that Enzyme has not yet been updated to guarantee compatibility with React 18.

The maintainer of @wojtekmaj/enzyme-adapter-react-17 (unofficial adapter for React 17) warns that enzyme is dead. The support of React 18 would require a complete rewrite of it. Here is the link https://dev.to/wojtekmaj/enzyme-is-dead-now-what-ekl

He suggests to either move to RTL or stick with React 16-17

Related