When using axios-mock-adapter in jest I somehow receive this error after the test passed. It seems like that the mock adapter is working and returns the correct result, but somehow the real http request is somehow executed in the background?
import axios from 'axios'
import MockAdapter from 'axios-mock-adapter'
const userSoeren: User = { id: 42, name: 'Sören' }
test('single client request is executed', async () => {
const axiosInstance = axios.create()
const axiosInstanceMock = new MockAdapter(axiosInstance)
axiosInstanceMock.onGet('/api/users').reply(StatusCodes.OK, [userSoeren])
const result = await axiosInstance.get('/api/users')
console.log(result)
expect(result.data).toEqual<User[]>([userSoeren])
})
When using
axios-mock-adapter
in jest I somehow receive this error after the test passed. It seems like that the mock adapter is working and returns the correct result, but somehow the real http request is somehow executed in the background?I've installed
axios@0.27.2
andaxios-mock-adapter@1.21.1
. Might this be related to https://github.com/ctimmerm/axios-mock-adapter/issues/338 ?