Testing useEffect and Mocking Components
In the previous chapter, you saw how test doubles can be used to verify network requests that occur upon user actions, such as clicking a submit button. We can also use them to verify side effects when our components mount, like when we're fetching data from the server that the component needs to function. In addition, test doubles can be used to verify the rendering of child components. Both use cases often occur together with container components, which are responsible for simply loading data and passing it to another component for display.
In this chapter, we’ll build a new component, AppointmentsDayViewLoader
, that loads the day’s appointments from the server and passes them to the AppointmentsDayView
component that we implemented in Chapter 2, Rendering Lists and Detail Views. By doing so, the user can view a list of appointments occurring today.
In this chapter, we will cover the following topics:
- Mocking...