-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering React Test-Driven Development
By :

So far in this chapter, you’ve built your own hand-crafted spy function, with support for stubbing values and with its own matcher. The purpose of that has been to teach you how test doubles work and to show the essential set of spy and stub patterns that you’ll use in your component tests.
However, our spy function and the toBeCalledWith
matcher are far from complete. Rather than investing any more time in our hand-crafted versions, it makes sense to switch to Jest’s own functions now. These work in essentially the same way as our spy
function but have a couple of subtle differences.
This section starts with a rundown of Jest’s test double functionality. Then, we’ll migrate the CustomerForm
test suite away from our hand-crafted spy function. Finally, we’ll do a little more cleanup by extracting more test helpers.
Here’s a rundown of Jest test...