Use axios MockAdapter history in JavaScript tests
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
After https://github.com/ctimmerm/axios-mock-adapter/pull/124 has been merged, we can replace
spyOn(axios, 'get');
// ...
expect(axios.get).toHaveBeenCalled();
with
const getCalls = axiosMock.history.find(config => config.method === 'GET');
expect(getCalls.length).toBe(1);
or even
const axiosCalls = axiosMock.history.find(config => config.method === 'GET' && config.url === 'http://expected.url');
expect(axiosCalls.length).toBe(1);
Edited by 🤖 GitLab Bot 🤖