VariantFactory
Creates complete items from another factory with preset overrides.
Use this factory to describe a named variation of a base factory without duplicating all the base defaults. The preset overrides are applied first, then any overrides passed to make can further customize the final item.
interface User { name: string; role: "user" | "admin"; active: boolean;}
const userFactory = new StaticFactory<User>({ name: "Test User", role: "user", active: true,});
const adminFactory = new VariantFactory<User>(userFactory, { role: "admin",});
const admin = adminFactory.make();// { name: "Test User", role: "admin", active: true }
const inactiveAdmin = adminFactory.make({ active: false });// { name: "Test User", role: "admin", active: false }Source
Section titled “Source”Source file: src/variant/variant-factory.ts
