I making a axios request which fails and throws error in catch block. In catch block I am making request to other end point to get results
router.get('/info', (req, res) => {
axios('www.getInformationApi.com')
.then(results => {
return res.status(200).json(results.data);
})
.catch(async(err) => {
if (err === 'server_down') {
try {
// need to improve test coverage for this lines
const secondsResults = await axios('www.getInformationApi2.com');
return res.status(200).json(secondsResults)
} catch (error) {
throw Error(error)
}
} else {
const error = errors.createEntError(err.message, errorList);
return res.status(constants.HTTP_SERVER_ERROR).json(error);
}
})
});
I like to write Unit test which covers "Axios" request in catch block using "nock" or "http-mocks"
Can I able to test using Unit test or do I need to run integration tests in this scenario