Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

basic-factory

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-factory

[![Build Status](https://travis-ci.org/bkd705/basic-factory.svg?branch=master)](https://travis-ci.org/bkd705/basic-factory)

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Basic Factory

Build Status

A basic tool providing an easy way to generate blocks of mock data for tests or as placeholders.

Basic Usage

  1. Install NPM package
  npm install --save-dev basic-factory
  // OR YARN
  yarn add --dev basic-factory
  1. Import Factory in {appDir}/helpers/factories.js
// ES6
import BasicFactory from 'basic-factory'
  1. Initialize a new Factory
const factory = BasicFactory()
  1. 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}`
  }
})
  1. Export your Factory instance
export default factory
  1. 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

FAQs

Package last updated on 28 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc