Mock Service Worker: Frontend Testing Without a Real Backend

Hands-on practice for this lecture. Work through the exercises and quizzes to reinforce what you've learned.

1

Exercise 1 of 1

API State Machine: Loading, Error, Success, Empty

Model all four fetch states explicitly — so MSW can test every path your component takes.

No loading state, no error handling

👤 User Profile

Joined:

❌ Switch between scenarios. While loading: blank card — no spinner, no placeholder. On error: silently empty — no message, no retry. On empty: indistinguishable from loading. MSW can intercept the request, but there's no UI to assert against.