Test-Driving Data Input
In this chapter, you’ll explore React forms and controlled components.
Forms are an essential part of building web applications, being the primary way that users enter data. If we want to ensure our application works, then invariably, that’ll mean we need to write automated tests for our forms. What’s more, there’s a lot of plumbing required to get forms working in React, making it even more important that they’re well-tested.
Automated tests for forms are all about the user’s behavior: entering text, clicking buttons, and submitting the form when complete.
We will build out a new component, CustomerForm
, which we will use when adding or modifying customers. It will have three text fields: first name, last name, and phone number.
In the process of building this form, you’ll dig deeper into testing complex DOM element trees. You’ll learn how to use parameterized tests to repeat a group of tests...