A simple model factory tool bases on Laravel's Eloquent factories
npm install designmynight/factorista --dev
This package is designed for easy use when no package builder (such as webpack) is being used.
We use this tool with Karma, in karam.conf.js
, add the files
files : [
'node_modules/faker/build/build/faker.js',
'node_modules/designmynight/factorista/index.js'
]
All functions available with Marak's Faker.js can be used
factoryDefine(User, (faker) => ({
first_name: faker.name.firstName(),
last_name: faker.name.lastName(),
}));
// make a single user
const user = factory(User).make();
// make mulitple users
const users = factory(User, 5).make();
// make users with overrides
const users = factory(User, 5).make((faker) => ({
first_name: 'Ralph',
last_name: faker.lorem.word()
}));