npm.io
1.0.4-0 • Published 8 years ago

mockutil

Licence
MIT
Version
1.0.4-0
Deps
2
Size
128 kB
Vulns
1
Weekly
0

A simple mockjs extended app

install

use npm:

npm install mockutil -D

use yarn:

yarn add mockutil -D
use
  1. touch mock.json
[
  {
    "url": "test/lib1",
    "method":"post",
    "template":{
      "string":"post"
    }
  },
  {
    "url": "test/lib2",
    "method":"get",
    "template":{
      "string":"get"
    }
  }
]
  1. import mockutil
const MockUtil = require('mockutil');
const json = require('./test.json');
  1. Instantiate objects
const mockutil = new MockUtil(json);
  1. replace your fetch/axios/request with mockutil instance
mockutil.get('test/lib2').then(res => {
  // balabala
})