fabrication

Fabricate real objects with fake data

npm install fabrication
2 downloads in the last week
10 downloads in the last month

Fabrication

Construct real Objects with fake data

The Fabrication module allows you to build fabricators that produce real objects from your codebase using fake data. It provides several aids to help in the process of populating fabricated Objects.

Basic usage

The main usage revolves around building fabricators that define how Objects should be fabricated. Building a simple fabricator just takes a function:

var fabrication = require('fabrication');

var userFabricator = fabrication.fabricator(function() {
  return new User(
    this.generate('integer', 1000),
    this.generate('fullName'),
    this.generate('emailAddress')
  );
});

var fakeUser = userFabricator();
// fakeUser => { id: 1, name: 'Arthur Dent', email: 'guide@galaxy.net' }

The above fabricator can be used to fabricate User Objects by calling the created fabricator function. It uses several other Fabrication methods available in the function's scope to populate the User Object with data.

Install

Fabrication can be installed using NPM:

$ npm install --save fabrication

Advanced Usage

The Fabication module provides more ways of building and calling fabricators and has several helper API's to aid the process of fabricating Objects. The module consists of three parts:

  1. fabricator: for building and calling Object fabricators
  2. generate: for generating data used in fabricators
  3. sequence: for generating sequence based data

See the docs and examples directory for more details on the apis and usage.

License

The MIT License (MIT)

Copyright (c) 2013, Mattijs Hoitink mattijs@monkeyandmachine.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you