Skip to content
UdemyReactPaid courseIntermediate levelCertificate

React Testing with Jest and Enzyme (Udemy.com)

Improve your React, Redux, Hooks and Context Code with Test Driven Development

Created by: Bonnie Schulkin

Last updated June 2024

icon
What you will learn

  • Write unit, integration and functional tests for React, Hooks, Contex and Redux using Jest and Enzyme.
  • Know the tradeoffs for different testing approaches and when to choose which approach.
  • Plan your React app more effectively via Test Driven Development.
  • Mock methods and modules to keep your tests isolated.

How it compares

Against the other 173 rated Udemy courses in React on CourseDuck:

  • Rating4.3 out of 5higher than 23% of them
  • Reviews4,654#22 of 174 by number of reviews
  • Length15.1 hourslonger than 52% of them
  • Last updatedJune 2024more recently than 59% of them

icon
Quality Score

Content Quality
/
Video Quality
/
Qualified Instructor
/
Course Pace
/
Course Depth & Coverage
/

Overall Score : 86 / 100

icon
Course Description

Please read the first lecture (reproduced at the end of this course description) before deciding to purchase this course.

In short, Enzyme is no longer actively supported. Unless you're interested in learning Enzyme specifically (because you're working on a legacy React project that uses Enzyme tests), I recommend taking a React Testing Library course instead.

**************************************************************************************************************

Take your React code to the next level by learning Test Driven Development (TDD) with Jest and Enzyme! Jest is a powerful, flexible testing framework, and Enzyme provides tools to test React and Redux applications. In this course, you will learn to test:

  • React hooks, including useEffect, useState and useReducer

  • Asynchronous functions using Axios

  • Redux action creators and reducers

  • Complex Redux action creators that use Redux Thunk

  • React context, including context with embedded state

You will also learn how to make the most of Jest capabilities, including

  • Mocking and restoring individual properties of modules

  • Mocking entire modules

  • Controlling which tests run using, .skip, and .only

  • Running test suites multiple times with different data, using .each

Please Note: This course does not cover Jest snapshots, as they are not compatible with the TDD mode of testing.

Why Learn to Test?

Test Driven Development will help you write better organized code that’s easier to maintain, which will save you time in the long run. Your tests provide value to your software development team, since others know they can rely on your code. Employers want developers with testing skills!

Unit tests and Functional Tests

This course focuses on unit tests. Unit tests are tightly coupled to specific areas of code, which leads to easy diagnosis of failures, and a great match for Test-Driven Development. The course also teaches functional tests, which are modeled on user flows (and resulting behavior from the user perspective). Functional tests are not connected to code, which makes them more difficult to diagnose, but more resilient to code refactors.

Learn the Reasons behind the Syntax

This course discusses tradeoffs when considering different approaches to testing, leaving you confident in the testing choices you make. Furthermore, you will deepen your understanding of React, Redux and Context as we dig into how and why we test each aspect.

Practice your New Skills

You will also have opportunities to practice what you’ve learned. There are occasional “quizzes” while we’re building the course projects, where you can apply what you learned, and then watch a video to see the solution. There are also two sets of challenges to extend the course projects, with solutions on GitHub.

**************************************************************************************************************

**************************************************************************************************************

This lecture/article is reproduced here, since Udemy articles do not preview well. Unfortunately, you will not get the full experience, as links are not available in the course description.

First lecture / article: The Author's Thoughts on Enzyme and React 18

The stark reality: Enzyme is not compatible with React 18, and probably never will be.

The History

I started writing this 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.

Since that time, a few things have happened: 

  • In June 2020, Enzyme switched from being maintained by Airbnb to being maintained by an individual.

  • In October 2020, React 17 was released.

  • Also in October 2020, an unofficial Enzyme adapter for React 17 was released.

  • In December 2021, the author of the unofficial adapter for React 17 wrote an article entitled Enzyme is Dead, where he stated that he would not be writing an adapter for React 18.

  • In March 2022, React 18 was released.

  • In April 2022, the Enzyme maintainer has stated that he will work on a React 17 adapter before a React 18 adapter.

  • As of April 2022, the official adapter for React 17 has not been released.


Why I currently recommend React Testing Library

React Testing Library 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 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 than Enzyme.


What all this means for this 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.

That said, there are still around 2.4 million downloads of Enzyme a week (as of April 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: 

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.


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.

icon
Udemy Discount

The discount is applied through our link. Open the course from here and Udemy's current promotional price is applied at checkout on most courses, no code to type.

Some courses are excluded from Udemy's promotions. If the price does not drop, clear your browser cookies and use the button again.

icon
Instructor Details

Bonnie Schulkin

My teaching career started when I played school with my (not very willing) younger brother as a kid. I gradually expanded my horizons to teaching (marginally) more willing high school students, and more recently have taught software development at various boot camps to delightfully willing adults. I have been working in the software industry on and off since the mid-90s, which predates the birth of many coders in the San Francisco tech scene(!).

icon
More courses by Bonnie Schulkin

$84.99

$69.99

icon
More React courses

$139.99

$94.99

$74.99

$69.99

$89.99

$99.99

icon
Reviews

4.3

4,654 ratings on Udemy

Select a bar to show only those reviews.Select the bar again to show every rating.

By Slobodan Stojkovic on 4/13/2022

This course is obsolute. Many lessons are without meaningful order, often with code that wasn't typed in lesson before, which makes it difficult to follow along and code. Quite a few times, in the middle of lesson and even in the middle of the sentence video is cut and then it jumps to other code and slides. Very bad user experience. Constant changing of recorded and then prerecorded voice overs and different volumes in them is not pleasant at all. On several occasions you will hear typing without anything being typed on screen. In context sections that typing is so strong and loud that it is irritating to listen. Unrelevant JS doc coping during the whole course, and few times typing them in mid lection just pollutes and makes code less readable. Person teaching this course makes mistakes all the time then corrects them so basicly there is no use of trying to type and learn code with her. All that followed by iritating remarks that we should take a drink if we noticed error. Overall, this course was a very bad experience and it was very tiresome to go through it because of its very low quality, constant code differentiations that don't follow up along with previous lectures, because even a single lectures that are short have several different audio parts put together and in each of them course maker sounds diferently. This course is also artificially extended by putting 4 hours of Legacy code lessons in it.

By Adrian Zawadzki on 4/12/2021

The explanation is understandable and accurate. It is pleasant to watch, the instructor, if you have any questions, will answer you comprehensively, accurately and quickly. I can definitely recommend it. However, I subtracted half a star because the code is missing for the lessons. It is true that there is a source code at the end, but that is not enough. This is a problem especially when I had to stop the course and come back to it after some time. Then I either start from scratch or download the finished code from the end of the course. Another example - Bonnie provided a link to a blog post about the differences between Enzyme and Testing Library. I had to rewrite the link. It is not a big problem, but it bothers me (by the way, very nice article). Anyway, I invested in another course (react-testing-library) by this author, because I rate the whole thing very positively.

By James Palotta on 11/7/2020

Thank you very much for this course

By Denny Lesmana on 11/1/2020

Good course for people who want to learn react unit testing from basic , Thanks !

By Natalie Mclaren on 10/23/2020

Although I wasn't completely new to javascript testing, this was my first time using Jest and Enzyme. After completing this course, I now feel comfortable enough to use Jest and Enzyme in my personal projects. There were a few times where I replicated what we had done in the course in a personal project and it was very easy to get my tests working as expected. I thought Bonnie described everything very well and used examples that were relevant and made it easy for me to understand what we were doing and why. The course covers a lot more than syntax and functions but also best practices for testing. A great course for any developer wanting to get started with Jest and Enzyme.

By Marc Hage on 10/17/2020

very good! best I found on tdd in react.

By Hayder Abood on 10/14/2020

Not recommended. This course has a lot of repetitive content and promotes bad practices by encourage testing the implementation details of the components instead of testing its desired behavior. Also, I couldn't find any major best practice recommendations except of very primitive and obvious ones. I want a refund!

By Satyajit Patnaik on 10/6/2020

Phew! That was a really nice way to finally wrap my head around unit testing in React. Thanks to Bonnie Schulkin's amazing course on React Unit Testing using Jest and Enzyme. This Udemy tutorial cleared a lot of confusions in my head which were stuck for a very long time from Angular-Jasmine world, like Spying and Mocking. Bonnie is a great instructor with her crisp and to-the-point explanations of concepts in React and how to unit test them. She teaches a lot of good coding design patterns through the series. Definitely, a must recommend for all the React beginners.

By Paritosh Yadav on 9/27/2020

Its a great resource for learning TDD in react...

By Diego Mateo Angulo Castaeda on 9/26/2020

The teacher should try to explain more in detail or deep the functionality of each method used, looks like she is only doing the test but not explaining the reason of why and how each method works

By Stacey Miller on 9/25/2020

I am really enjoying the explanations they are clear and paced well. I also like the discussions about the trade-offs as that is super important for the workplace!

By Julien Brub on 9/23/2020

? I like the teacher's style.
? She speaks very clearly, so the course is easy to understand, even at higher speeds.
? The included option drinking game is a nice little touch.
There is a lot of content, showing alternatives to solve the same problem.

Showing 12 of 363 reviews