Created
April 18, 2022 17:08
-
-
Save enzzoperez/195a771ae16eee4c1a8768e9399e699e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('testing error in request', async () => { | |
const mock = new MockAdapter(axios); | |
mock.onGet().reply(404, {data: []}); //or mock.onGet().networkError(); | |
const {result, waitForNextUpdate} = renderHook( | |
({url}) => useRemoteData({url}), | |
{ | |
initialProps: { | |
url: '', | |
}, | |
}, | |
); | |
await waitForNextUpdate(); | |
expect(result.current.error).toBeTruthy(); | |
expect(result.current.response).toBeFalsy(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment