You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
axios
.post(url, payload)
.then((res) => {
if (res.error) {
throw res.error; // **_THIS PART, WHERE WE HAVE ERROR AS IN RESPONSE_**
}
const someVar= res.data;
})
.catch((error) => {
if (error.response && error.response.status === 403) {
do something here...
} else {
do something else here...
}
});
For the above code even after defining res as :- const mockData = { error: { response: { message: "Some error caught :/", status: 403 } } }
And passing it to mock.onPost().reply(200,mockData);
That line is not getting covered.
The text was updated successfully, but these errors were encountered:
notKvS
changed the title
Not able to cover throw.error, when status is 200 and response contains an error field.
Not able to cover throw res.error, when status is 200 and response contains an error field.
Nov 2, 2021
For the above code even after defining res as :-
const mockData = { error: { response: { message: "Some error caught :/", status: 403 } } }
And passing it to mock.onPost().reply(200,mockData);
That line is not getting covered.
The text was updated successfully, but these errors were encountered: