Vue-Resource-Mock
This package requires no specific version of Vue but vue-resource. It works for both Vue/Vue2 as the time of this writing.
Copy and modified from https://github.com/airtonix/vue-resource-mock
Open to PR/Issue :)
Usage
Install
After npm install vue-resource-mock --save-dev
,
Vue if devMode // don't use it on your production build Vue // after use vue-resource
Mock data
// basic mock { // before respond, you can check the path and query parameters with `pathMatch` & `query` // powered by 'url-pattern' & 'qs' // https://www.npmjs.com/package/url-pattern // https://www.npmjs.com/package/qs // to pass through this mock, call the 4th parameter as a function, the return value will be ignored let body = /* whatever */ return body: body status: 200 statusText: 'OK' headers: /*headers*/ delay: 500 // millisecond } // shorthand mock 'PUT */path/to/resource': 200 // respond with only status code 'POST */path/to/resource': /*whatever*/ // respond with only body, status code = 200
TODO
- Rewrite in typescript
- UT
License
MIT