In this chapter:
- Setting up an environment for testing React applications
- An overview of different React testing tools
- Testing component in integration or isolation
- Snapshot testing
- Testing component’s styles
- Stories and component-level acceptance testing
When you’ve got a top-notch mixer, instead of wasting time whisking eggs and sugar, you can focus on improving other aspects of your craft, like refining your recipes or decorating your cakes.
Similarly to how superb equipment enables pastry chefs to focus on more significant aspects of their craft, front-end frameworks and libraries, like React, allow you to focus on more significant aspects of writing web applications. Instead of focusing on manipulating the DOM — removing, inserting, and updating elements yourself — you can focus on your application’s usability, accessibility, and business logic.
In this chapter, you’ll learn how to test React applications and how it relates to what you’ve learned about testing front-end applications. You’ll learn how tools like JSDOM can still be useful in different contexts, and learn concepts which will help test any other front-end frameworks you may use.
I’ve chosen to write these examples using React mainly because of its popularity. I believe it’s the tool with which most of my readers will already be familiar.