Chapter 3: Testing Complex Components with React Testing Library
In Chapter 2, Working with React Testing Library, we learned how to test presentational components. However, most features are designed to allow user actions that result in changes to the state and resulting output. Testing as many user action scenarios as possible is essential for reducing risk before sending code to production for end users. By the end of this chapter, you will learn how to simulate user actions with the fireEvent
and user-event
modules. You will learn how to test components that interact with web service APIs. Finally, you will learn how to use test-driven development as a workflow for building your features.
In this chapter, we're going to cover the following topics:
- Performing actions on components with the
fireEvent
module - Simulating Document Object Model (DOM) events with the
user-event
module - Testing components that interact with APIs
- Implementing test-driven development...