Type-safe test data factories for Drizzle ORM (v1.2.0). Introspects your schema at runtime to automatically generate sensible fixture values with zero configuration. Supports PostgreSQL, MySQL, SQLite, CockroachDB, and SingleStore. Active development with frequent releases. Key differentiators vs @praha/drizzle-factory: automatic value inference, built-in faker.js integration, defineSeeder for DB seeding, and test framework helpers for Vitest/Jest. Peer dependency on drizzle-orm >=0.29.0. Ships TypeScript types.
npm install drizzle-fixturesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic factory setup, build methods, database creation, overrides, multiple records, faker integration, and related record creation using use().
Use import syntax or switch to dynamic import() if in CommonJS project.
Ensure every Drizzle table used with defineFactory has a primary key column defined in schema.
Install @faker-js/faker as devDependency if you intend to use buildWithFaker().
Replace seed() calls with defineSeeder({ ... }) and invoke the returned function.Wrap test suites with createVitestHelpers(db) to automatically roll back after each test.
Add "type": "module" to package.json, or use dynamic import: const { defineFactory } = await import('drizzle-fixtures');Use named import: import { defineFactory } from 'drizzle-fixtures';Add a primary key (e.g., id integer primary key) to your Drizzle table definition.
Pass your Drizzle database instance as the first argument: userFactory.create(db);