Skip to content

Add test fixture factory templates with faker.js #26

@PAMulligan

Description

@PAMulligan

Description

Add test fixture factory templates to the project setup that use `@faker-js/faker` for generating realistic test data. The `data-seeder` agent references faker.js patterns, but the generated project templates don't include factory utilities.

Why

Every API needs test data. Without factories, developers write ad-hoc test objects that are inconsistent and tedious to maintain. Factory templates give every generated project a standard pattern for creating test entities with realistic data.

Acceptance Criteria

  • Add `@faker-js/faker` as a dev dependency in `setup-project.sh`
  • Create a `tests/fixtures/factory.ts` template with:
    • A generic `createFactory()` function
    • A `userFactory` example using the generated user schema
    • Support for overrides (`userFactory({ name: 'Custom' })`)
    • Support for creating multiple (`userFactory.createMany(5)`)
  • Create a `tests/fixtures/index.ts` that exports all factories
  • Add an example usage in the generated health test or a new test file
  • CI passes

Example

```typescript
// tests/fixtures/factory.ts
import { faker } from '@faker-js/faker';

export function userFactory(overrides?: Partial): NewUser {
return {
email: faker.internet.email(),
name: faker.person.fullName(),
...overrides,
};
}
```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions