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.
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.