4
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 ...
Get Mastering React Test-Driven Development - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.