This is a great article! Thank you for this!
How would you throw exceptions to test for api call failures?
For example, if you had a try / catch block for,
const profile = yield call(getProfile, action.profileId);
When you test the saga as a whole, how do you force an error?
I tried using to mockImplementation to return a new Error(), but that doesn't go into the catch block.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a great article! Thank you for this!
How would you throw exceptions to test for api call failures?
For example, if you had a try / catch block for,
const profile = yield call(getProfile, action.profileId);
When you test the saga as a whole, how do you force an error?
I tried using to mockImplementation to return a new Error(), but that doesn't go into the catch block.