Values in dataModels
Apart from generating stuff based on faker
there is number of ways to get your own toys in play.
Static fields
If defined method won't be found in faker.js it will be treated as simple string to be used as field value
var userDataModel = {
staticField: 'someValue'
};
fixtureFactory.register('user', userDataModel);
fixtureFactory.generateOne('user');
expect
{
staticField: 'someValue'
}
Functions
You may define a function in the data model which will be processed after all other fixtures have been generated
var userDataModel = {
name: 'name.firstName',
email: function(fixtures) {
return fixtures.name + '@acme.com';
}
};
fixtureFactory.register('user', userDataModel);
fixtureFactory.generateOne('user');
expect
{
staticField: '<generated name>@acme.com'
}
Updated less than a minute ago