-
Notifications
You must be signed in to change notification settings - Fork 0
zpx8179033/nodeMocker
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
node下的mock工具 node下的mock工具 支持对象和数组多层嵌套 /** * 数据配置example * 支持array,object,int,float,string等类型 * 以上类型可以采用|后跟单数值表示特定值, * 也可以采用 1-100这种方式表示数值范围, * 还可以采用['a','b','c']这种方式表示字符串的取值范围 * 简单数组 string|['a','b'] * 暂时只支持@name,@date,@bool,@dateTimestamp这几种特殊类型,统一采用随机生成数据 * data: { name: "@name", birthday: "@date", age:"int|18-50", page:"string|['qwe','asd','zxc']", source:"int|9", isBool:"@bool", isBoolean:"bool|true", imgList:[{ url: "string|['a','b','c']", birthday: "@date", time:"@dateTimestamp", }], userInfo:{ name: "@name", birthday: "@date", age:"int|18-50", } } * @type {{isMock: boolean, checkUrl: ((url))}} */ 使用方法 ------------------------------------------------------------------ 在网站根路径添加名称为nodemocker.config.js的配置文件 配置信息如下demo ------------------------------------------------------------------ demo ------------------------------------------------------------------- let mockConfig={ isOpen: true, urlData: [ { url: '/node/abc', data: { code: 'int|0', imgList : [{ url: "url|['http://img0.imgtn.bdimg.com/it/u=546683621,3971380670&fm=27&gp=0.jpg','http://img.taopic.com/uploads/allimg/120105/2014-120105115U136.jpg','http://www.taopic.com/uploads/allimg/120525/189103-12052514152699.jpg']", des: "string|['123','456','789']", isSelected: '@bool', }] } }, { url: '/node/abc1', data: { code: 'int|0', imgList : [{ url: "url|['http://img0.imgtn.bdimg.com/it/u=546683621,3971380670&fm=27&gp=0.jpg','http://img.taopic.com/uploads/allimg/120105/2014-120105115U136.jpg','http://www.taopic.com/uploads/allimg/120525/189103-12052514152699.jpg']", des: "string|['123','456','789']", isSelected: '@bool', }] } } ] } module.exports = mockConfig; -------------------------------------------------------------------
About
node mock tools
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published