ctimmerm / axios-mock-adapter

Axios adapter that allows to easily mock requests
MIT License
3.46k stars 245 forks source link

New mocks don't overwrite old mock. #269

Closed gwuah closed 4 years ago

gwuah commented 4 years ago

I don't know if there's some caching functionality in this library but new mocks are not working. It only returns the previous mock value. Any help?

ctimmerm commented 4 years ago

Could you give an example of the issue you're facing?

gwuah commented 4 years ago

I can't even reproduce the issue but i was able to make headway by going through this pr https://github.com/ctimmerm/axios-mock-adapter/issues/116.

Incase anyone faces this same issue,

zivanovica commented 8 months ago

I am facing exactly the same issue- I even have it like this

` let axiosMock: MockAdapter;

beforeEach(() => { axiosMock = new MockAdapter(axios); });

afterEach(() => { axiosMock.restore(); });`

and I use replyOnce but which ever test is first in execution order it takes "advantage" and then the next one that's mocking same url but negative case simply ignores it- I even tried having reset and restore within the test itself.