Goodbye Enzyme. Future of Unit Testing in React v.18

Sviat Kuzhelev
5 min readJun 6, 2022
Original image link at computerweekly.com

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” — Martin Fowler

React Unit testing — is one of the essential parts to keep UI components' behavior consistent. It allows us to test any UI scenario in various ways. Either positive or negative test case, you and your team will precisely understand what it’s going on under the hood.

It’s been almost 3 months since React v.18 was officially released and yet question about whether or not enzyme (and its close companion enzyme-adapter-react) library will be compatible bothers our minds.

🔮 In this story, I would love to show you how to easily migrate from Enzyme to recommended by Facebook for unit testing React-Test-Rerender library.

Will Enzyme support React v.18

There are different rumors, but the reality seems to be not so rosy. The official statement says that even React v.17 support was not planned by Enzyme and enzyme-adapter-react. However, it didn’t stop our community to design a non-official way on behalf of wojtekmaj/enzyme-adapter-react-17 package.

💡Since then it was the only way to bypass non-supported…

--

--

Sviat Kuzhelev
Sviat Kuzhelev

Written by Sviat Kuzhelev

Senior Software Engineer | Passionate About Web 🔨 | AI Enthusiast | Open Source Contributor | Love 🐈, 🎒+⛰️, and 🎿 | LinkedIn 👉 t.ly/2bBKJ