The Git tag for this section is adding-spies. It contains solutions to the exercises from the previous chapter, so if you haven't completed the Exercises section yourself, then you should move to this tag now so that you're up to date.
For more detailed instructions, see the To get the most out of this book section in the Preface.
For more detailed instructions, see the To get the most out of this book section in the Preface.
In Chapter 2, Test-driving Data Input with React, we wrote some tests that didn't use the normal Arrange-Act-Assert test format. Here's a reminder of how one of those tests looked, from the CustomerForm test suite:
it('saves existing value when submitted', async () => {
expect.hasAssertions();
render(
<CustomerForm
firstName="Ashley"
onSubmit={customer =>
expect(customer.firstName).toEqual('Ashley')
}
/>
);
ReactTestUtils.Simulate...