Repository navigation
feat(templates): add faker-backed test fixture factories (#26) - #143
Merged
Merged
Conversation
… 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>
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #26.
Generated projects now include test data factories backed by
@faker-js/faker:tests/fixtures/factory.ts: a genericcreateFactory<T>(generate)returning a callable factory withbuild(),createMany(count, overrides)(object or per-index function), a 1-based sequence for unique fields, andreset(); plusseedFactories()for reproducible data and auserFactorybuilt onNewUserfrom the users schema. Columns with database defaults are left unset so results go straight intodb.insert(users).values(...).tests/fixtures/index.ts: single re-export point.tests/fixtures/tenancy.ts(multi-tenant projects only):tenantFactorywith unique slugs andprojectFactory; 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/fakeradded to the generated dev dependencies;User/NewUsertypes exported from the shared schema.Type safety: a new
tsconfig.fixtures.jsonintemplates/snippetstype-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 thetdd-from-schemaskill's helper example points at the factories.Test plan
templates/snippets:pnpm typecheckpasses for cloudflare, node, lambda, and fixtures configs--cloudflareproject: 29 tests pass includingfixtures.test.ts--node --multi-tenantproject: 60 tests pass;tests/fixtures/index.tsre-exports the tenancy factoriestsc(exactOptionalPropertyTypes, noUncheckedIndexedAccess) in both projectspnpm test(framework script tests): 381 pass, setup-project expectations updated for the new files🤖 Generated with Claude Code