Skip to main content

Practice ยท 2 of 3

Async Collaborator Stub

Write makeFetchStub(routes) โ€” routes maps URL to a response body (object). Returns a fetch-like async (url) => ({ ok: true, status: 200, json: async () => routes[url] }) for known URLs, and { ok: false, status: 404, json: async () => null } for unknown ones. The stub must record requested URLs in .requests (array, in order).

Difficulty: intermediate

Back to lesson: Practice: Seams & Doubles โ€” Practice