Reader small image

You're reading from  Create React App 2 Quick Start Guide

Product typeBook
Published inFeb 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789952766
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Brandon Richey
Brandon Richey
author image
Brandon Richey

Brandon Richey is a software engineer and a React enthusiast who has written several popular React tutorials. He has been making professional and hobby programming projects spanning healthcare, personal sites, recruiting, and game development for nearly 20 years! Brandon is the author of the Packt book 'Create React App 2 Quick Start Guide'.
Read more about Brandon Richey

Right arrow

Keep Your App Healthy with Tests and Jest

An important part of any application developer's life is making sure that their application runs properly the first time, every time. That can be a difficult thing to do as applications get more complicated; what might have previously required just a few minutes and a single line of code to clean up or fix might instead start taking hours, days, or even weeks (or longer) to try to fix! In addition, if you're trying to build up your application and make it work cleanly and effectively.

In this chapter, we will cover the following topics:

  • The history of testing React applications
  • Different ways to run React tests
  • A brief introduction to Jest
  • A brief introduction to the test watcher
  • How to write tests

The why and when of testing

You might be wondering why we've started tackling our tests so late in our application. Generally speaking, when you're just starting out in your projects, you might wait a little bit to see how your application shakes out before you start verifying its behavior with tests. That being said, we're now also at a really good point to start shoring up our project and make it something that we can deploy to production with confidence!

The history of testing React

Again, it's great to understand the history of the toolset to understand why certain features or libraries are being used. When people were just getting started with React, ideas and standards around testing were absolutely...

Summary

Testing is something that's absolutely critical to the overall health of your application! It ensures your development cycles are sane and your deploys are not incredibly dangerous. Your behavior can be tested, verified, and you can be confident in what your application is doing at any point in time without ever needing to open up a browser!

This is something that used to be a nightmare to do. The React test setup was a function that people generally hated given how much of a time commitment it took and how finicky it ended up being after the setup was done. One misstep or bad configuration change and the entire test harness framework could fall apart completely!

Be prepared to write a lot of tests if you write a production-ready React application! It's a great software engineering practice to be do whenever you're doing anything code-wise, and React is...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Create React App 2 Quick Start Guide
Published in: Feb 2019Publisher: PacktISBN-13: 9781789952766
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Brandon Richey

Brandon Richey is a software engineer and a React enthusiast who has written several popular React tutorials. He has been making professional and hobby programming projects spanning healthcare, personal sites, recruiting, and game development for nearly 20 years! Brandon is the author of the Packt book 'Create React App 2 Quick Start Guide'.
Read more about Brandon Richey