Skip to content

Commit f890d6f

Browse files
perf($package.json): integrate axios-mock-adapter
1 parent 4122050 commit f890d6f

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
"@mdi/font": "4.7.95",
3737
"@types/lodash": "4.14.149",
3838
"axios": "0.19.0",
39+
"axios-mock-adapter": "1.17.0",
3940
"class-validator": "0.11.0",
4041
"core-js": "3.6.1",
4142
"lodash": "4.17.15",
42-
"mockjs": "^1.1.0",
4343
"roboto-fontface": "*",
4444
"vue": "2.6.11",
4545
"vue-class-component": "7.1.0",

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import '@mdi/font/css/materialdesignicons.css'
88
import '@/directives/throttled-click'
99
import '@/directives/debounced-click'
1010
import { listenToColorScheme } from '@/plugins/adaptive-color-scheme'
11-
import '@/plugins/mock'
11+
import '@/plugins/axios-mock-adapter'
1212

1313
Vue.config.productionTip = false
1414

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const axios = require('axios')
2+
const MockAdapter = require('axios-mock-adapter')
3+
4+
// All requests using this instance will have a 2 seconds delay:
5+
const mock = new MockAdapter(axios, { delayResponse: 2000 })
6+
7+
// Mock GET request to /users when param `searchText` is 'John'
8+
// arguments for reply are (status, data, headers)
9+
mock.onGet('/api/getDemo').reply(200, {
10+
message: '/api/getDemo success!'
11+
})
12+
13+
mock.onGet('/api/delay').reply(200, {
14+
message: 'delay message'
15+
})

src/plugins/mock/index.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)