Open crazyair opened 3 months ago
import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; const instance = axios.create({ adapter: config => { console.log('no run'); return axios({ ...config, adapter: undefined }); }, }); const mock = new MockAdapter(instance); mock.onGet('/users').reply(config => { return new Promise(resolve => { setTimeout(() => { resolve([200, { timeout: config.timeout }]); }, config.timeout); }); }); instance.get('/users').then(data => { console.log('data', data); });
What's the question here? console.log('no run'); isn't logged. The adapter never gets called as it gets mocked with new MockAdapter(instance)
console.log('no run');
new MockAdapter(instance)