May 2019
Intermediate to advanced
496 pages
10h 38m
English
When we're writing tests, we isolate the unit under test. Sometimes (but not always) that means we avoid exercising any of the collaborating objects. That can be for a number of reasons: sometimes it helps us work toward our goal of independent tests, and sometimes it's because those collaborating objects have side-effects that would complicate our tests.
For example, with React components we sometimes want to avoid rendering child components because they perform network requests when they are mounted.
A test double is an object that acts in place of a collaborating object. In Chapter 2, Test-driving Data Input with React, you saw an example of a collaborator: the onSubmit function, which is a prop passed to both
Read now
Unlock full access