Skip to content

feat(templates): add faker-backed test fixture factories (#26) - #143

Merged
PAMulligan merged 1 commit into
mainfrom
feature/issue-26-fixture-factories
Sep 9, 2026
Merged

PAMulligan merged 1 commit into
mainfrom
feature/issue-26-fixture-factories

Conversation

@PAMulligan

Copy link
Copy Markdown
Contributor

Summary

Closes #26.

Generated projects now include test data factories backed by @faker-js/faker:

  • tests/fixtures/factory.ts: a generic createFactory<T>(generate) returning a callable factory with build(), createMany(count, overrides) (object or per-index function), a 1-based sequence for unique fields, and reset(); plus seedFactories() for reproducible data and a userFactory built on NewUser from the users schema. Columns with database defaults are left unset so results go straight into db.insert(users).values(...).
  • tests/fixtures/index.ts: single re-export point.
  • tests/fixtures/tenancy.ts (multi-tenant projects only): tenantFactory with unique slugs and projectFactory; setup-project appends their export to the index.
  • tests/fixtures.test.ts: example usage covering single build, overrides, createMany, per-index overrides, seeding, and insert-shape compatibility.
  • @faker-js/faker added to the generated dev dependencies; User/NewUser types exported from the shared schema.

Type safety: a new tsconfig.fixtures.json in templates/snippets type-checks the fixture files in the Type-check Embedded Templates job, alongside the existing three configs. The generated README gains a "Test data" section, and the tdd-from-schema skill's helper example points at the factories.

Test plan

  • templates/snippets: pnpm typecheck passes for cloudflare, node, lambda, and fixtures configs
  • Generated --cloudflare project: 29 tests pass including fixtures.test.ts
  • Generated --node --multi-tenant project: 60 tests pass; tests/fixtures/index.ts re-exports the tenancy factories
  • Generated fixture files pass a strict standalone tsc (exactOptionalPropertyTypes, noUncheckedIndexedAccess) in both projects
  • pnpm test (framework script tests): 381 pass, setup-project expectations updated for the new files
  • CI green

🤖 Generated with Claude Code

… projects

Every generated project now ships tests/fixtures/ with a generic
createFactory<T>() (overrides, createMany with per-index overrides, a
sequence for unique fields, reset) and a userFactory built on the users
schema, plus tests/fixtures.test.ts as living documentation and
@faker-js/faker as a dev dependency. Multi-tenant projects also get
tenantFactory and projectFactory. The schema now exports User/NewUser, the
snippet type-check covers the fixtures via tsconfig.fixtures.json, and the
generated README and tdd-from-schema skill point at the factories.

Closes #26

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added area: skills Claude Code skills area: scripts Automation scripts area: templates Starter templates area: ci-cd CI/CD workflows labels Sep 9, 2026
@PAMulligan
PAMulligan merged commit 3cdc90b into main Sep 9, 2026
15 checks passed
@PAMulligan PAMulligan mentioned this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci-cd CI/CD workflows area: scripts Automation scripts area: skills Claude Code skills area: templates Starter templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test fixture factory templates with faker.js

1 participant