Create a new factory instance
Define an attribute on this factory
Name of attribute
Define an attribute on this factory using a default value (e.g. a string or number)
Name of attribute
Default value of attribute
Define an attribute on this factory using a generator function
Define an attribute on this factory using a generator function and dependencies on options or other attributes
Name of attribute
Array of dependencies as option or attribute names that are used by the generator function to generate the value of this attribute
Value generator function. The generator function will be called with the resolved values of the dependencies as arguments.
Define multiple attributes on this factory using a default value (e.g. a string or number) or
generator function. If you need to define dependencies on options or other attributes, use the
attr
method instead.
Returns an object that is generated by the factory.
The optional option likelihood
is a number between 0 and 100 that defines the probability
that the generated object contains wrong data. This is useful for testing if your code can
handle wrong data. The default value is 100, which means that the generated object always
contains correct data.
Returns an array of objects that are generated by the factory.
The optional option likelihood
is a number between 0 and 100 that defines the probability
that the generated object contains wrong data. This is useful for testing if your code can
handle wrong data. The default value is 100, which means that the generated object always
contains correct data.
Extend this factory with another factory. The attributes and options of the other factory are merged into this factory. If an attribute or option with the same name already exists, it is overwritten.
Define an option for this factory using a default value. Options are values that are not
directly used in the generated object, but can be used to influence the generation process.
For example, you could define an option withAddress
that, when set to true
, would generate
an address and add it to the generated object. Like attributes, options can have dependencies
on other options but not on attributes.
Name of option
Default value of option
Define an option for this factory using a generator function. Options are values that are not
directly used in the generated object, but can be used to influence the generation process.
For example, you could define an option withAddress
that, when set to true
, would generate
an address and add it to the generated object. Like attributes, options can have dependencies
on other options but not on attributes.
Define an option for this factory using a generator function with dependencies in other
options. Options are values that are not directly used in the generated object, but can be
used to influence the generation process. For example, you could define an option
withAddress
that, when set to true
, would generate an address and add it to the generated
object. Like attributes, options can have dependencies on other options but not on attributes.
Name of option
Array of dependencies as option names that are used by the generator function to generate the value of this option
Value generator function with dependencies in other options. The generator function will be called with the resolved values of the dependencies as arguments.
Define an auto incrementing sequence attribute of the object. Default value is 1.
Name of attribute
Define an auto incrementing sequence attribute of the object where the sequence value is generated by a generator function that is called with the current sequence value as argument.
Define an auto incrementing sequence attribute of the object where the sequence value is generated by a generator function that is called with the current sequence value as argument and dependencies on options or other attributes.
Factory for building JavaScript objects, mostly useful for setting up test data