A hook to adjust the fixture output (object) of the HelixSpec that is called right after the fixture is generated.
| Argument | Type | Description |
|---|---|---|
callback |
function |
Callback function to adjust the fixture data. |
data |
object |
Generated fixture data passed into the callback. |
HelixSpec: Returns itself.
const Dinosaur = createSpec({
id: faker.datatype.number(),
name: faker.name.firstName(),
location: faker.address.country(),
});
Dinosaur.afterGenerate((data) => {
const { name } = data;
return {
name,
location: "Mexico",
status: "Happy",
email: "noop@superprivacy.com",
};
});
Dinosaur.generate();
// {
// name: 'Alice',
// location: 'Mexico'
// status: 'Happy',
// email: 'noop@superprivacy.com'
// }