Basics
Let's go through basic steps needed to get swinging. We will take care of registering model for generating simple fixtures.
Register your model
At first you need to register a blueprint
to have something to generate from
var fixtureFactory = require('fixture-factory');
var userDataModel = {
firstName: 'name.firstName',
lastName: 'name.lastName',
};
fixtureFactory.register('user', userDataModel);
Generate your first fixture
var userFixture = fixtureFactory.generateOne('user');
expect userFixture
to equal
{
firstName: <generated first name>,
lastName: <generated last name>
}
Let's generate ten more
Generating more fixture is as simple as getting the first one
var userFixtures = fixtureFactory.generate('user', 10);
expect to get
[
{
firstName: <generated first name>,
lastName: <generated last name>
},
...9 more
]
Updated less than a minute ago