basic-factory
v1.0.1
Published
[![Build Status](https://travis-ci.org/bkd705/basic-factory.svg?branch=master)](https://travis-ci.org/bkd705/basic-factory)
Downloads
15
Readme
Basic Factory
A basic tool providing an easy way to generate blocks of mock data for tests or as placeholders.
Basic Usage
- Install NPM package
npm install --save-dev basic-factory
// OR YARN
yarn add --dev basic-factory
- Import Factory in
{appDir}/helpers/factories.js
// ES6
import BasicFactory from 'basic-factory'
- Initialize a new Factory
const factory = BasicFactory()
- Register your Factory generators
factory.register('User', () => {
// Would probably use Faker or something to generate these fields randomly.
return {
username: `user${Math.random() * 100}`,
email: `user${Math.random() * 100}`
}
})
- Export your Factory instance
export default factory
- Use factory in other files
import factory from '{appDir}/helpers/factories'
const oneUser = factory.create('User')
const arrayOfUsers = factory.createMany('User', 5)
Project Development
yarn
/npm install
yarn test
/npm run test
Contributing
See CONTRIBUTING.md