-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Labels
Description
I'm trying to test my interceptor logic, whether calling the error reporter (like Sentry), showing toast error, and resetting the auth state if we received a 401 response from our server. The problem that we're facing is that we got the following error every time we ran the test:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "AxiosError".]
{
code: 'ERR_UNHANDLED_REJECTION'
}Based on Interceptors Docs we need to return a rejected promise on the second parameter (onRejected) for the interceptor, but when I remove the Promise.reject calls (just returning the error), the test successfully ran.
But that turns out to break my app.
Additional info that might help
- Stackblitz to reproduce https://stackblitz.com/edit/node-wsmxdh?file=index.test.ts
Any idea how I test my interceptor logic without breaking my app? Thanks in advance!
Reactions are currently unavailable