Udemy
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Development
Web Development Data Science Mobile Development Programming Languages Game Development Database Design & Development Software Testing Software Engineering Development Tools No-Code Development
Business
Entrepreneurship Communications Management Sales Business Strategy Operations Project Management Business Law Business Analytics & Intelligence Human Resources Industry E-Commerce Media Real Estate Other Business
Finance & Accounting
Accounting & Bookkeeping Compliance Cryptocurrency & Blockchain Economics Finance Finance Cert & Exam Prep Financial Modeling & Analysis Investing & Trading Money Management Tools Taxes Other Finance & Accounting
IT & Software
IT Certification Network & Security Hardware Operating Systems Other IT & Software
Office Productivity
Microsoft Apple Google SAP Oracle Other Office Productivity
Personal Development
Personal Transformation Personal Productivity Leadership Career Development Parenting & Relationships Happiness Esoteric Practices Religion & Spirituality Personal Brand Building Creativity Influence Self Esteem & Confidence Stress Management Memory & Study Skills Motivation Other Personal Development
Design
Web Design Graphic Design & Illustration Design Tools User Experience Design Game Design Design Thinking 3D & Animation Fashion Design Architectural Design Interior Design Other Design
Marketing
Digital Marketing Search Engine Optimization Social Media Marketing Branding Marketing Fundamentals Marketing Analytics & Automation Public Relations Advertising Video & Mobile Marketing Content Marketing Growth Hacking Affiliate Marketing Product Marketing Other Marketing
Lifestyle
Arts & Crafts Beauty & Makeup Esoteric Practices Food & Beverage Gaming Home Improvement Pet Care & Training Travel Other Lifestyle
Photography & Video
Digital Photography Photography Portrait Photography Photography Tools Commercial Photography Video Design Other Photography & Video
Health & Fitness
Fitness General Health Sports Nutrition Yoga Mental Health Dieting Self Defense Safety & First Aid Dance Meditation Other Health & Fitness
Music
Instruments Music Production Music Fundamentals Vocal Music Techniques Music Software Other Music
Teaching & Academics
Engineering Humanities Math Science Online Education Social Science Language Teacher Training Test Prep Other Teaching & Academics
AWS Certification Microsoft Certification AWS Certified Solutions Architect - Associate AWS Certified Cloud Practitioner CompTIA A+ Cisco CCNA Amazon AWS CompTIA Security+ Microsoft AZ-900
Graphic Design Photoshop Adobe Illustrator Drawing Digital Painting InDesign Character Design Canva Figure Drawing
Life Coach Training Neuro-Linguistic Programming Personal Development Mindfulness Personal Transformation Life Purpose Meditation CBT Emotional Intelligence
Web Development JavaScript React CSS Angular PHP Node.Js WordPress Vue JS
Google Flutter Android Development iOS Development React Native Swift Dart Programming Language Mobile Development Kotlin SwiftUI
Digital Marketing Google Ads (Adwords) Social Media Marketing Google Ads (AdWords) Certification Marketing Strategy Internet Marketing YouTube Marketing Email Marketing Retargeting
Microsoft Power BI SQL Tableau Business Analysis Data Modeling Business Intelligence MySQL Data Analysis Blockchain
Business Fundamentals Entrepreneurship Fundamentals Business Strategy Business Plan Startup Online Business Freelancing Blogging Home Business
Unity Game Development Fundamentals Unreal Engine C# 3D Game Development C++ 2D Game Development Unreal Engine Blueprints Blender
2021-03-25 22:17:57
30-Day Money-Back Guarantee
IT & Software Other IT & Software React

2021 Update! React Testing with Jest and Enzyme

Improve your React, Redux, Hooks and Context Code with Test Driven Development
Rating: 4.5 out of 54.5 (3,029 ratings)
17,401 students
Created by Bonnie Schulkin
Last updated 4/2021
English
English [Auto]
30-Day Money-Back Guarantee

What you'll 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.
Curated for the Udemy for Business collection

Requirements

  • Basic Familiarity with JavaScript and React

Description

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.

Who this course is for:

  • Web developers interested in improving their React apps with testing

Featured review

Welington Silva
Welington Silva
27 courses
3 reviews
Rating: 4.5 out of 5a year ago
Such a very clear and nicely distributed content. Bonnie gives us a very easy to follow content, well paced and a good laugh once in a while. The content is very complete so I would totally recommend this for begginer/intermediary testers and a very useful resource for advanced ones. Congratulations for such an awesome course, Bonnie!

Course content

16 sections • 205 lectures • 15h 5m total length

  • Preview03:22
  • TDD: What and Why
    Preview03:44
  • Preview03:05
  • Next lecture is optional
    00:13
  • OPTIONAL: Setting up Jest without create-react-app
    07:46
  • Demo of Jest Watch Mode
    04:00
  • More about Jest Watch Mode, Test Files and Tests
    05:40
  • Enzyme vs. React Testing Library
    06:52
  • IMPORTANT NOTE: enzyme-adapter-react-17 not yet available
    00:28
  • Enzyme Introduction and Setup
    04:26
  • Using Enzyme in a Test
    03:34
  • Jest Assertions
    04:00
  • Types of Tests
    03:00
  • Testing Tradeoffs
    06:58
  • Why There is no Snapshot Testing in this Course
    03:10

  • Course Repository on GitHub
    00:06
  • Demo and Start Click Counter App
    02:52
  • Set up Enzyme and Write Tests
    05:55
  • data-test Attributes
    06:01
  • First data-test Attribute Test
    04:02
  • OPTIONAL: Removing data-test Attributes for Production
    08:44
  • More data-test Attribute Tests
    04:09
  • DRY Refactor
    06:50
  • Strategies and Design Decisions
    05:11
  • Test Initial Counter Display
    06:40
  • Test Button Click
    05:40
  • Acceptance Testing and Review
    03:05
  • Click Counter Challenges
    02:19
  • Click Counter Challenge Descriptions
    00:17

  • Jotto App Demo
    01:49
  • Jotto App Planning
    04:17
  • Jotto App Plan of Attack
    03:36
  • Set up Jotto App and Congrats Component
    07:22
  • Congrats Component Test Setup
    07:25
  • Congrats Tests and the .text() Method
    05:43
  • Code the Congrats Component
    03:17
  • Notes about PropTypes Testing
    01:02
  • OPTIONAL PropTypes Testing
    10:38
  • OPTIONAL Code PropTypes and Update Tests
    03:41
  • OPTIONAL Default Props in setup()
    02:29
  • Move Enzyme Configuration to setupTests.js
    02:14
  • Summary of Abstractions
    02:08
  • Playing the Long Game
    02:18

  • Set up GuessedWords Component and Tests
    04:06
  • GuessedWords PropTypes and setup()
    08:18
  • Use `describe` for Context
    01:51
  • Write Tests and beforeEach for "no words guessed"
    04:56
  • Code for "no words guessed"
    03:12
  • Tests for "nonzero guessed words"
    06:22
  • Code for "nonzero guessed words"
    05:15
  • Manual Acceptance Testing
    03:44
  • Bootstrap Styling
    04:10

  • Code Quiz! Basic Input Component
    02:30
  • Input Component Props
    04:44
  • OPTIONAL: Introduction to React Hooks
    04:28
  • Mocking React Methods
    04:02
  • Prepare Input Component for useState Tests
    05:11
  • State-Controlled Field Tests and Code
    07:34
  • Common Questions about Mocking React Methods
    06:21
  • Clearing State-Controlled Field on Submit
    08:24
  • Testing Input Render for `success` as `true` or `false`
    08:29
  • `getLetterMatchCount` Helper Function
    08:36

  • Introduction to Functional Tests, and update App Component
    04:49
  • Set up Functional Tests
    08:43
  • First Functional Test: Submit Guess with No Previous Guesses
    07:23
  • Code Quiz! Functional Tests for "Some Words Guessed" and "Correct Guess"
    06:28
  • Jest methods: .only() .skip() and .todo()
    05:13

  • `secretWord` Plan
    01:49
  • `moxios`: Why and How
    03:32
  • Set up `getSecretWord` Action and Tests
    04:10
  • Testing Async Actions
    02:37
  • Write `getSecretWord` Action
    05:00
  • Asynchronous Action and Moxios Summary
    02:02

  • Mocking Modules with Jest
    05:58
  • Using useEffect to Get Secret Word on App Mount
    04:43
  • Mocking the actions Module
    05:30
  • Testing that useEffect is Called on App Mount, Not Called on App Update
    05:52
  • Write useEffect Code to Pass Tests
    02:01
  • Choice point: Redux or React Context?
    04:43

  • Redux Planning
    04:56
  • Set up Redux
    05:36
  • Success State Planning
    01:00
  • `CORRECT_GUESS` Action Creator
    07:05
  • `successReducer` Test
    06:52
  • OPTIONAL: Introduction to the `useSelector` Hook
    02:31
  • Testing Redux State for Input Component
    03:48
  • Choices for Testing `useSelector`
    05:45
  • `storeFactory` Test Helper
    03:54
  • Updating Setup Function to use Store Factory
    04:05
  • Summary: Intro to Redux Testing
    03:28

  • Other Pieces of State
    01:00
  • `guessedWords` Planning
    03:13
  • Redux Thunk: What and Why
    01:24
  • Installing Redux Thunk
    03:35
  • Thunk Test Planning
    02:32
  • Set up `guessWords` Tests
    08:49
  • First Thunk Test
    05:47
  • Add `secretWordReducer`
    02:08
  • Remaining Tests
    07:13
  • Write Reducer and Action Creator
    06:52
  • Plan for Functional Tests
    05:10
  • Update Components
    04:01
  • Thunk Testing Summary
    01:37

Instructor

Bonnie Schulkin
Teacher | Coder | Mediocre Bassist
Bonnie Schulkin
  • 4.6 Instructor Rating
  • 3,363 Reviews
  • 32,373 Students
  • 3 Courses

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.

  • Udemy for Business
  • Teach on Udemy
  • Get the app
  • About us
  • Contact us
  • Careers
  • Blog
  • Help and Support
  • Affiliate
  • Impressum Kontakt
  • Terms
  • Privacy policy
  • Cookie settings
  • Sitemap
  • Featured courses
Udemy
© 2021 Udemy, Inc.