axios-mock-shim
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -142,3 +142,3 @@ /* eslint-disable */ | ||
// mock api | ||
_mock(configs); | ||
_mock.call(this, configs); | ||
// Important!! Don't remove this return | ||
@@ -145,0 +145,0 @@ // This return stays for Promise mechanism |
{ | ||
"name": "axios-mock-shim", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "A plugin build for easily using axios-mock-adapter with axios", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -97,6 +97,22 @@ # Axios Mock Shim | ||
- **mock** | ||
Trigger the mock feature without calling run, by default, calling `run` will trigger mock automatically, but sometimes we just want to define specific response with some params. | ||
> Just like `with`, if `useMock` is set to `false`, this method will skip the mock. avoiding you from calling `mock` accidently in production mode. | ||
```js | ||
// Define some special situation response in dev | ||
if (process.env.NODE_ENV === 'development') { | ||
const getInfos = [{ id: 3000 }, { | ||
test: 'This is test data', | ||
}]; | ||
// trigger as folloing will let Shim plugin cache result for the params without calling a request | ||
api.use('post', 'buy', getInfos[0]).with([400, getInfos[1]]).mock(); | ||
} | ||
``` | ||
- **run()** | ||
Execute the `AxiosRequest` | ||
Execute the `AxiosRequest`, will execute real request by axios with auto checking for mock cache, if there's no cache yet, will mock & cache the result. | ||
@@ -103,0 +119,0 @@ |
21901
322