In this chapter, we'll look at the most involved piece of the TDD puzzle: test doubles.
The unit in unit testing refers to the single function or component that we focus on for the duration of that test. The Act phase of a test should involve just one action on one unit. But units don't act in isolation: functions and components collaborate and depend on other units. Your application can be thought of as a web of dependencies, and test doubles help us to design and test those dependencies.
The following topics will be covered in this chapter:
- What is a test double?
- Submitting forms using spies
- Stubbing the fetch API
- Extracting test helpers