Isolate the seam
A unit test should test your code, not the network, the clock, or a random source. Replace those with a mock so the test is fast, offline, and deterministic. The test then checks how your code reacts to a response you control, which is the part you own.
Mock the failure too
The value of a mock is that you can make it fail whenever you want. Error handling, retries, and timeouts are branches you cannot reach by waiting for the real world to misbehave. A mock reaches them on command, which is how you test the paths that matter most in production.