Udemy, Enzyme and React 18
Tags: enzyme, testing, udemy, react
Published: 2022-06-02 22:14:42

<figcaption>Photo by <a href="https://unsplash.com/@sigmund?utm_source=medium&amp;utm_medium=referral" data-href="https://unsplash.com/@sigmund?utm_source=medium&amp;utm_medium=referral" class="markup--anchor markup--figure-anchor" rel="photo-creator noopener" target="_blank">Sigmund</a> on&nbsp;<a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral" data-href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral" class="markup--anchor markup--figure-anchor" rel="photo-source noopener" target="_blank">Unsplash</a></figcaption>
---
I’ve gotten some questions about my [Udemy course on Enzyme](https://www.udemy.com/course/react-testing-with-jest-and-enzyme/?referralCode=3A42BF689E28CADB0587) in light of the React 18 release, so I wanted to write an article with my thoughts.

## Enzyme and React 18

tl;dr: Enzyme is not compatible with React 18, and probably never will be. I recommend React Testing Library instead.

## The History

I started writing the Udemy course in March 2018, and it was published in May 2018. At that time, Enzyme was the primary option for testing React components with Jest. React Testing Library (Enzyme’s current prime competitor) had [just been released in March 2018](https://github.com/testing-library/react-testing-library/compare/v0.0.0...v0.1.0).

Since that time, a few things have happened:

*   In June 2020, Enzyme [switched from being maintained by Airbnb to being maintained by an individual](https://medium.com/airbnb-engineering/phase-ii-enzyme-d9efa717e297).
*   In October 2020, [React 17 was released](https://reactjs.org/blog/2020/10/20/react-v17.html).
*   Also in October 2020, an [unofficial Enzyme adapter for React 17](https://github.com/wojtekmaj/enzyme-adapter-react-17/releases/tag/v0.2.0) was released.
*   In December 2021, the author of the unofficial adapter for React 17 wrote [an article entitled Enzyme is Dead](https://dev.to/wojtekmaj/enzyme-is-dead-now-what-ekl), where he stated that he would not be writing an adapter for React 18.
*   In March 2022, [React 18 was released](https://github.com/facebook/react/releases/tag/v18.0.0).
*   In April 2022, the Enzyme maintainer has stated that [he will work on a React 17 adapter before a React 18 adapter](https://github.com/enzymejs/enzyme/issues/2556#issuecomment-1086869881).
*   As of June 2022, [the official adapter for React 17](https://github.com/enzymejs/enzyme/issues/2429) has not been released.

## Why I currently recommend React Testing Library

[React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) and Enzyme do the same job: rendering components so that they can be tested with Jest. I recommend React Testing Library over Enzyme for these reasons:

1.  Unlike Enzyme, [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) does not rely on React internals. This means React Testing Library **does not have an adapter** that needs to be updated with each release of React, and is far less likely to have issues with new React versions.
2.  I find React Testing Library to be [easier to use](https://dev.to/bonnie/testing-react-a-converts-journey-from-enzyme-to-testing-library-5ai0) than Enzyme.

## What all this means for the Udemy course

Now that React 18 has come out and there’s no React 17 adapter in sight, I don’t believe there’s a future for Enzyme. I **would not recommend this course** for people who are looking to learn how to test new React applications. Instead I would recommend you find a course on React Testing Library. (I have [a recommendation](https://www.udemy.com/course/react-testing-library/?referralCode=0B60E8FEB40F0D159E84) 😂 — see my [website](https://bonnie.dev/courses) for coupons)

That said, there are still [around 2.1 million downloads of Enzyme](https://www.npmjs.com/package/enzyme) a week (as of June 2022). Here are the circumstances under which I would recommend learning Enzyme:

1.  You are working on a legacy project that already has a large suite of Enzyme tests, and the project never intends to upgrade to React 18.
2.  You are working on a project with a large suite of existing Enzyme tests, and you wish to understand these tests before migrating to React Testing Library (RTL). However, Wojciech Maj, the author of the unoffiical Enzyme adapter for React 17, [suggests](https://dev.to/wojtekmaj/enzyme-is-dead-now-what-ekl):

> While [Migrate from Enzyme support article](https://testing-library.com/docs/react-testing-library/migrate-from-enzyme) 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.

## The Bottom Line

Enzyme was a great way to test React applications when this course came out; however, I can no longer recommend it. I encourage you to study React Testing Library instead.