Skip to content

Instantly share code, notes, and snippets.

@Goldziher
Created August 1, 2021 06:43
Show Gist options
  • Save Goldziher/655dd93b1b297e5764054bb6f9cc6a2a to your computer and use it in GitHub Desktop.
Save Goldziher/655dd93b1b297e5764054bb6f9cc6a2a to your computer and use it in GitHub Desktop.
Example UserDTO factory
import * as faker from 'faker';
import { FixtureFactory } from 'interface-forge';
import { UserDTO } from '@shared/dto/User.dto';
export const UserDTOFactory = new FixtureFactory<UserDTO>(() => ({
id: faker.datatype.uuid(),
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
isActive: true,
email: faker.internet.email(),
location: faker.address.city(),
employer: faker.company.companyName(),
profession: TypeFactory.iterate([
'Chef',
'Programmer',
'Fighter Pilot',
'Slob',
]),
phoneNumber: faker.phone.phoneNumber(),
imageUrl: faker.internet.url(),
birthDate: faker.date.past(faker.datatype.number({ min: 20, max: 80 })),
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment