-
Notifications
You must be signed in to change notification settings - Fork 42
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
mockAxios.create() may return a new instance of mockAxios #59
Comments
Hi, I agree that there is indeed room for improvement when using multiple axios instances. I'll see how it can be improved over the weekend. |
Hi, so I implemented the desired behavior in the This works, but it adds a significant new problem: If you create separate This is somewhat unsatisfactory and I need to think a little bit more about this and how this can be changed to be more backward-compatible (any input welcome!) |
I am getting this error ( I am assuming it is tied to this new update)
I have a singular instance being created in my file.
|
I'm hitting the issue with different instances of axios - is that going to get released? Seems that the fix is in. |
@httpete The patch for this is still not merged but only in the branch linked above. As described above I was (and still am) hesitant to merge this in as it would break existing, more simple usages of this library. I'm still unsure how to solve this appropriately. Any input welcome. |
my $0.02: when using instances of axios, they should be passed in. in other words, a class that calls i would expect the |
The link does not appear to work anymore. In my case I use multiple axios instances each configured with it's own interceptor. This seems to wipe out the axios instance that I create. In the end I just implemented by own https://stackoverflow.com/a/71961832/242042 |
Assuming the following use case:
Basic test scenario:
Because mockAxios works with a shared state, a workaround would be to override the
create
method and simply return a shalow copy of mockAxios (as in the following example) Sinceaxios.create()
actually appears to be a factory, the mock could also return a new instance. I think this would be ideal. What do you guys think?The text was updated successfully, but these errors were encountered: