mockinator
v0.0.2
Published
Mockinator is a powerful library for generating mock data based on predefined schemas. It supports a variety of data types, including numbers, strings, booleans, arrays, objects, and custom data generators. This makes it ideal for testing and prototyping
Downloads
2
Maintainers
Readme
Mockinator
Mockinator is a powerful library for generating mock data based on predefined schemas. It supports a variety of data types, including numbers, strings, booleans, arrays, objects, and custom data generators. This makes it ideal for testing and prototyping applications where you need consistent, realistic mock data.
Installation
npm install zod # npm
yarn add zod # yarn
With Yarn
yarn add mockinator
Usage
import m from 'mockinator';
const myNumberSchema = m.number().min(10).max(20);
console.log(myNumberSchema.generate()) // number between 10 to 20
import m from 'mockinator';
let UserSchema = m.object({
id: m.string().length(10),
age: m.number().min(18).max(99),
friends: m.string().length(10).array(3),
luckyNumber: m.oneOf([1,2,3,4]),
pets: m.array(m.oneOf(['Dog', 'Cat', 'Mouce'])).length(3),
});
const user = UserSchema.generate();
console.log(user);