industrial
v1.1.0
Published
Factory toolkit for node testing suites
Downloads
3
Readme
Industrial.js
Object factory toolkit for robust testing data
Usage
This package is in its infancy and usage is subject to change without warning.
Industrial allows you to describe a tree-like structure, and gives you tools to recall and store data from the tree-like structure for testing purposes.
let industrial = require('industrial')
let myFactory = new industrial.Factory({
username: 'Brian',
hobby: 'Quadcopter Yoga'
}, function( user ) {
user.variant( 'beekeepers', {
hobby: 'Bees'
})
user.variant( 'fpv_racers', {
hobby: 'FPV Racing'
}, function(user) {
user.variant( 'morty', {
name: 'Morty Smith'
})
})
})
/* Now the tree structure looks like this
Brian
Quadcopter Yoga
| \
| \
| \
Brian Brian
FPV Racing Bees
|
|
|
Morty Smith
FPV Racing
*/
// Builds all users including root node of the tree
let allUsers = myFactory.buildAll()
// Builds all users starting at the 'fpv_racers' node
let allUsers = myFactory.buildAll('fpv_racers')
// => [ { name: 'Brian', hobby: 'FPV Racing' }, { name: 'Morty Smith', hobby: 'FPV Racing' }]
// Access nested nodes
let allUsers = myFactory.buildAll('fpv_racers.morty')
*/
Database wiring
The configuration variable takes a single create
hook.
new Factory( baseObject, callbackChain, {
create: function( testObjects ) {
// Do something with your tests objects to create them
return // return something e.g. a promise, or the objects
// buildAll will return the value returned here
}
})