gulp-mock
Gulp plugin to mock data (for test you know).
Install
npm install --save-dev gulp-mock
Usage
All mock template must put in the source path. All mocked files would be in the api path. apiPath, sourcePath, dirName are required.
// in gulpfile.jsvar gulp = connect = mock = ; const sourcePath = 'source';const apiPath = 'api'; mock; gulp; gulp;
Need live reload and jsonp support?
Gulp-mock use middleware to handle live reload and jsonp response.
gulp; gulp;
Mock template
Mocked data would like this:
Date filter use momment.js, see docs
data: // "data|2-10" Should return a array, the array's length should within 2 to 10 code: "byother" // "String:7" Should return a string, the string's length should equal to 7. percent: "upinstr" tels: 7558816198259 // "Number:13|x.xxxxxxxxxxxxxxx" Should return a number and transformed like 'x.xxxxxxxxxxxxxxx'. 4997925737872 4765942785888 array: "oeverymajo" // "String:7-12" Should return a string, the string's length should within 7 to 12. "utplaysnbson" "lationabo" "actorso" "terandp" "nisedassha" "rtainhispla" "ainhigh" time: "2015-01-23" onal: // Random key name, in case sometime we need that. name: "the.grea" // "String:7|xxx.xxxx" Just work. time: "reemine" dt: 3782816532 name: "sus.anna" time: "tilabou" tth: 5975610705 name: "ces.andc" time: "ndbroug" lon: 2345818821 name: "rig.htsh" time: "eoftheb" clu: 6192378209 name: "few.reco" time: "olarshi" hts: 4497031601 avatar: "data:image/png;base64,iVBORw0KGg..." // "Image|200x200" Canvas Image, with 200px width and 200px height. thumbnails: "data:image/png;base64,iVBORw0KGg..." // "Image|200x300-400x500" Canvas Image, with 200px to 300px width and 400px to 500px height. "data:image/png;base64,iVBORw0KGg..." "data:image/png;base64,iVBORw0KGg..." "data:image/png;base64,iVBORwAADM..." "data:image/png;base64,iVBORw0KGg..." // and more
You also can write a mock template like this:
It'll return an array, and it's length should within 2 to 5.
Also you can skip "2-5"
, it'll return a array which length should within 1 to 20.