Skip to content

Commit 2554141

Browse files
exoegomarcbachmann
authored andcommitted
Use AxiosMockAdapter throughout README
1 parent 113656e commit 2554141

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)
@@ -279,15 +279,15 @@ If you set `onNoMatch` option to `passthrough` all requests would be forwarded o
279279
```js
280280
// Mock all requests to /foo with HTTP 200, but forward
281281
// any others requests to server
282-
var mock = new MockAdapter(axiosInstance, { onNoMatch: "passthrough" });
282+
var mock = new AxiosMockAdapter(axiosInstance, { onNoMatch: "passthrough" });
283283

284284
mock.onAny("/foo").reply(200);
285285
```
286286

287287
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.
288288

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

292292
mock.onAny("/foo").reply(200);
293293

@@ -325,7 +325,7 @@ Composing from multiple sources with Promises:
325325
```js
326326
var normalAxios = axios.create();
327327
var mockAxios = axios.create();
328-
var mock = new MockAdapter(mockAxios);
328+
var mock = new AxiosMockAdapter(mockAxios);
329329

330330
mock
331331
.onGet("/orders")

0 commit comments

Comments
 (0)