5
Mocking the API
In the previous chapter, we built the application pages that use test data. The UI of the pages is complete, but the pages are not functional yet. We are using the test data without making requests to the API.
In this chapter, we will learn what mocking is and why it is useful. We will learn how to mock the API endpoints with the msw library, a great tool that allows us to create mocked API endpoints that behave as real-world API endpoints.
We will also learn how to model the data of our application entities with the @mswjs/data library.
In this chapter, we will cover the following topics:
- Why is mocking useful?
- Introduction to MSW
- Configuring data models
- Configuring request handlers for API endpoints
By the end of this chapter, ...
Get React Application Architecture for Production now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.