I need to use stubs for requests to external resources, but still I need to fulfil requests for internal resources. Is it possible to mock a request from Axios only for certain URLs and otherwise continue to execute the initial requests?
export const spyOnAxios = (expectedResponse) => {
return jest.spyOn(axios, 'post')
.mockImplementation(function () {
if (arguments[0] === 'https://external-api.com') {
return expectedResponse
}
return performOriginalRequest()
})}