node-factory
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

Node Factory

version issues issues

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();

Author

Readme

Keywords

Package Sidebar

Install

npm i node-factory

Weekly Downloads

302

Version

0.4.2

License

MIT

Unpacked Size

37.1 kB

Total Files

31

Last publish

Collaborators

  • olavo.a.santos