This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Schema | |
type HostedImage { | |
url: String, | |
assetId: String, | |
} | |
type Author { | |
image: Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install fixture-factory --save-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fixtureFactory = require('fixture-factory'); | |
//create definition which will be used as a blueprint for generator methods | |
var userBlueprint = { | |
firstName: 'name.firstName', | |
lastName: 'name.lastName', | |
email: 'internet.email', | |
city: 'address.city', | |
country: 'address.country' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fixtureFactory = require('fixture-factory'); | |
var userBlueprint = { | |
firstName : 'name.firstName' | |
}; | |
fixtureFactory.register('user', userBlueprint); | |
fixtureFactory.generateOne('user', { | |
firstName: function (fixture, options, dataModel, faker) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fixtureFactory = require('fixture-factory'); | |
fixtureFactory.generateOne('user', { | |
role: 'admin' | |
}); | |
//will return standard user object with injected role: 'admin' field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fixtureFactory = require('fixture-factory'); | |
var userBlueprint = { | |
age: { | |
method: 'random.number', | |
//let's pass some options around | |
options: { | |
min: 18, | |
max: 90 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fixtureFactory = require('fixture-factory'); | |
fixtureFactory.generateOne('user'); | |
//will return single JSON object | |
fixtureFactory.generate('user', 10); | |
//will return array of 10 objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fixtureFactory = require('fixture-factory'); | |
//create definition which will be used as a blueprint in factory | |
var userBlueprint = { | |
firstName: 'name.firstName', | |
lastName: 'name.lastName', | |
email: 'internet.email', | |
city: 'address.city', | |
country: 'address.country' | |
}; |