Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1 KB

File metadata and controls

42 lines (33 loc) · 1 KB

afterGenerate(callback(data) => { ... })

A hook to adjust the fixture output (object) of the HelixSpec that is called right after the fixture is generated.

Arguments

Argument Type Description
callback function Callback function to adjust the fixture data.
data object Generated fixture data passed into the callback.

Returns

HelixSpec: Returns itself.

Example

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'
// }