Mock axios requests for testing
Mock axios requests for testing
$ npm install moxios --save-dev
…
describe('some-thing', () => {
let axiosInstance;
beforeEach(() => {
axiosInstance = axios.create();
moxios.install(axiosInstance);
})
afterEach(() => {
moxios.uninstall(axiosInstance)
})
it('should axios a thing', (done) => {
moxios.stubRequest('http://www.somesite.com/awesome-url', {
status: 200,
responseText: '…'
})
axiosInstance.get('http://www.somesite.com/awesome-url')
.then(res => assert(res.status === 200))
.finally(done)
})
})
moxios is heavily inspired by jasmine-ajax
MIT
No open issues yet, or sync has not completed.