Member-only story

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 React v.17 by Enzyme.

Meanwhile, something encouraging has been shared with us in the official thread regarding React v.18 support. Besides that, no one knows how and when it’s going to match our expectations.

Dreams about supporting React v.18 and about over Enzyme seem to be melting down like ice cream on a sunny day faster and faster.

Way out in Unit testing

Whether or not we gonna gave our ❤️ to Enzyme, it’s time to move forward. For me, it’s a personal tragedy since over the last years I wrote more than 500+ tests on top of Enzyme.

It took me some time to realize that nothing, but wasting the time is going around Enzyme. Time spent sitting for a miracle could be invested in writing new tests over another Unit testing ENV.

Eventually, instead of reinventing the wheel or searching for 3rd party solutions in Unit…

--

--

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

Responses (2)

Write a response