1.0.4-0 • Published 6 years ago
mockutil v1.0.4-0
A simple mockjs extended app
install
use npm:
npm install mockutil -D
use yarn:
yarn add mockutil -D
use
- touch mock.json
[
{
"url": "test/lib1",
"method":"post",
"template":{
"string":"post"
}
},
{
"url": "test/lib2",
"method":"get",
"template":{
"string":"get"
}
}
]
- import mockutil
const MockUtil = require('mockutil');
const json = require('./test.json');
- Instantiate objects
const mockutil = new MockUtil(json);
- replace your fetch/axios/request with mockutil instance
mockutil.get('test/lib2').then(res => {
// balabala
})