Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
moxios with a axios instance
Browse files Browse the repository at this point in the history
added documentation on how to use moxios with a specific axios instance
  • Loading branch information
falconmick authored and anilanar committed May 27, 2018
1 parent b84c3f7 commit 22ec6fb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ describe('mocking axios requests', function () {
})
```

## Mocking a axios.create() instance

```
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: reducedAsxResponse
});
axiosInstance.get('http://www.somesite.com/awesome-url')
.then(res => assert(res.status === 200))
.finally(done);
});
});
```

## Thanks

moxios is heavily inspired by [jasmine-ajax](https://github.com/jasmine/jasmine-ajax)
Expand Down

0 comments on commit 22ec6fb

Please sign in to comment.