generate-factory_skill

This skill auto-generates test data factories from schemas or models, accelerating test setup with realistic, deterministic fixtures.
  • TypeScript

92

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill jmagly/aiwg --skill generate-factory

  • SKILL.md8.3 KB

Overview

This skill auto-generates test data factories from schemas, TypeScript types, ORM models, or OpenAPI specs. It creates realistic, reusable factory code using faker mappings and optional deterministic seeding to make test setup fast and reliable. Use it to replace hard-coded fixtures and reduce boilerplate across unit and integration tests.

How this skill works

The generator analyzes input sources (TypeScript interfaces, Prisma schemas, JSON Schema, or OpenAPI) and maps fields to appropriate faker methods using a semantic type/name mapping. It outputs TypeScript factory modules with build, buildList, traits, and relationship helpers. Optional deterministic mode seeds faker to produce reproducible test data and batch commands create factories for all models in a codebase.

When to use it

  • Bootstrapping test infrastructure for a new project
  • Converting hard-coded fixtures into dynamic factories
  • Updating test data after schema or model changes
  • Generating many realistic variations for property-based or integration tests
  • Creating deterministic data for flaky-test reduction and CI

Best practices

  • Review and customize the type-to-faker mapping for domain-specific fields
  • Use traits for common variations (admin, inactive, recent) instead of inline overrides
  • Seed faker in deterministic mode for CI and snapshot tests
  • Generate related factories and buildWithX helpers to keep relationships explicit
  • Keep generated factories in a test/factories folder and import types from source code

Example use cases

  • Generate userFactory, orderFactory, and related factories from Prisma schema for integration tests
  • Batch-generate factories from src/types/ before a test migration to update all fixtures
  • Create deterministic builds in beforeEach by setting faker.seed(12345) for stable snapshots
  • Replace hard-coded test objects with factory.build({...}) to reduce duplication
  • Produce sample seed data for local development using the same factory definitions

FAQ

It supports TypeScript interfaces, Prisma schema files, JSON Schema, database migrations, and OpenAPI specs.

How do I get reproducible test data?

Use deterministic mode by calling faker.seed(seed) globally in tests or by using per-factory buildDeterministic(seed) helpers.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational