How can I mock this axios import with sinon and then use expectations ? I have tried:
import axios from 'axios';
axiosMock = sinon.mock(axios);
but the expectation fails :
describe('Random test', () => {
it('should run the test', async () => {
axiosMock.withArgs(sinon.match.any).once();
await getName();
}
}
The function under test is :
import axios, { AxiosRequestConfig } from 'axios';
async function getName() {
const config: AxiosRequestConfig = {
method: 'GET',
url: ' someUrl',
headers: {},
};
const res = await axios(config);
return res;
}