Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New mocks don't overwrite old mock. #269

Closed
gwuah opened this issue Jul 7, 2020 · 3 comments
Closed

New mocks don't overwrite old mock. #269

gwuah opened this issue Jul 7, 2020 · 3 comments

Comments

@gwuah
Copy link

gwuah commented Jul 7, 2020

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
Copy link
Owner

ctimmerm commented Jul 7, 2020

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

@gwuah
Copy link
Author

gwuah commented Jul 9, 2020

I can't even reproduce the issue but i was able to make headway by going through this pr #116.

Incase anyone faces this same issue,

  • make sure both the request url and the data you're sending matches exactly.
  • call mock.reset() after every test case.

@gwuah gwuah closed this as completed Jul 9, 2020
@zivanovica
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants