-
Notifications
You must be signed in to change notification settings - Fork 248
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
Ability to switch mocking on
and off
#43
Comments
All that axios-mock-adapter does is setting an adapter for the axios instance that you pass to it. var mock = new MockAdapter(axios);
// Save a reference to the mock adapter so that we can later reuse it
var mockAdapter = axios.defaults.adapter;
// Removing mocking behavior
mock.restore();
// Add mocking behavior again
axios.defaults.adapter = mockAdapter; |
Indeed, it is easy to achieve, I just thought maybe having a built in support might be helpful, since its not a lot of code and won't have any effect on existing code. It's a nice to have kinda feature. |
This would be as trivial to do if there is an option or if there's not: if (process.env.NODE_ENV === 'development') {
// Mocking code here
} If it was as an option it'd be basically the same, let's say the option was called const mock = new MockAdapter(axios, {
active: process.env.NODE_ENV === 'development'
}); So IMHO it doesn't make sense to implement it. |
very good |
I would be nice to have the ability to turn mocking
on
during development. The library currently has the methodreset
, which removes the handlers, andrestore
which removes mocking from axios. However, there is currently no possiblity to stop mocking, remember the added handlers and start mocking again. Think the opposite ofrestore
, but on an already initialized adapter.Or it's already possible and I can't figure out why.
The text was updated successfully, but these errors were encountered: