Skip to content

Commit 93d8398

Browse files
committed
Use AxiosMockAdapter throughout README
1 parent 4492f3c commit 93d8398

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Mocking a `GET` request
2121

2222
```js
2323
var axios = require("axios");
24-
var MockAdapter = require("axios-mock-adapter");
24+
var AxiosMockAdapter = require("axios-mock-adapter");
2525

2626
// This sets the mock adapter on the default instance
27-
var mock = new MockAdapter(axios);
27+
var mock = new AxiosMockAdapter(axios);
2828

2929
// Mock any GET request to /users
3030
// arguments for reply are (status, data, headers)
@@ -41,10 +41,10 @@ Mocking a `GET` request with specific parameters
4141

4242
```js
4343
var axios = require("axios");
44-
var MockAdapter = require("axios-mock-adapter");
44+
var AxiosMockAdapter = require("axios-mock-adapter");
4545

4646
// This sets the mock adapter on the default instance
47-
var mock = new MockAdapter(axios);
47+
var mock = new AxiosMockAdapter(axios);
4848

4949
// Mock GET request to /users when param `searchText` is 'John'
5050
// arguments for reply are (status, data, headers)
@@ -65,7 +65,7 @@ To add a delay to responses, specify a delay amount (in milliseconds) when insta
6565

6666
```js
6767
// All requests using this instance will have a 2 seconds delay:
68-
var mock = new MockAdapter(axiosInstance, { delayResponse: 2000 });
68+
var mock = new AxiosMockAdapter(axiosInstance, { delayResponse: 2000 });
6969
```
7070

7171
You can restore the original adapter (which will remove the mocking behavior)
@@ -277,15 +277,15 @@ If you set `onNoMatch` option to `passthrough` all requests would be forwarded o
277277
```js
278278
// Mock all requests to /foo with HTTP 200, but forward
279279
// any others requests to server
280-
var mock = new MockAdapter(axiosInstance, { onNoMatch: "passthrough" });
280+
var mock = new AxiosMockAdapter(axiosInstance, { onNoMatch: "passthrough" });
281281

282282
mock.onAny("/foo").reply(200);
283283
```
284284

285285
Using `onNoMatch` option with `throwException` to throw an exception when a request is made without match any handler. It's helpful to debug your test mocks.
286286

287287
```js
288-
var mock = new MockAdapter(axiosInstance, { onNoMatch: "throwException" });
288+
var mock = new AxiosMockAdapter(axiosInstance, { onNoMatch: "throwException" });
289289

290290
mock.onAny("/foo").reply(200);
291291

@@ -323,7 +323,7 @@ Composing from multiple sources with Promises:
323323
```js
324324
var normalAxios = axios.create();
325325
var mockAxios = axios.create();
326-
var mock = new MockAdapter(mockAxios);
326+
var mock = new AxiosMockAdapter(mockAxios);
327327

328328
mock
329329
.onGet("/orders")

0 commit comments

Comments
 (0)