Mock HTTP at the network, not the function that calls it
Mocking fetchUser tests that your code calls fetchUser. Mocking the HTTP request tests that your code handles the response, including the headers and the 500.
server.use(http.get("/api/users/42", () => HttpResponse.json({ id: 42, name: "Priya" })));msw for the browser and Node, nock for Node only. The code under test runs unchanged, all the way to the socket.
testing