node-factory
v0.4.2
Published
Easy way to generate random data for your tests
Downloads
1,444
Readme
Node Factory
When developing or testing your application, you might need to mock data comming from a database or an endpoint. Instead of manually generating "random" data, you can use model factories. This package allows you to define a default set of attributes for each of your endpoints or models and easily mock responses.
Docs
Check out our documentation for APIs and examples at https://olavoasantos.github.io/node-factory/
Installation
If you're using yarn
:
yarn add -D node-factory
Or, if you're using npm
:
npm install --save-dev node-factory
Usage
// 1. Import the factory generator
import { factory } from 'node-factory';
// 2. Create a factory
interface User {
id: string;
name: string;
email: string;
}
const UserFactory = factory<User>(fake => ({
id: fake.datatype.uuid(),
name: fake.name.findName(),
email: fake.internet.email(),
}));
// 3. Generate data
UserFactory.make();