Node-Mocker
mock service and http api with nodejs.
Features
- js config file,modify and effective
- mock services
- mock http api power by koa2
Requirements
- Node v6.0+
config
module //log inner mock server services: // mock service key: 4 // return number { ; return `hello1 !`; } { // return Promise return { ; }; } { throw Error'say2 Error!'; } proxyServers: // mock http,each will start a http server port: 8081 routes: '[GET]/api/shops/:shopId': // return a object a: 'a' b: 'b' { // or a function ctxbody = ctxparamsitemId; } port: 8082 routes: '[GET]/api/test': c: 'c' d: 'd' e: 'e' { ctxbody = `siteId111:`; } ;
Use
npm i n-mocker
const mocker = path; await mockerstart;
Workflow
npm install
npm run test