You know the pattern: you write a factory with faker, tests pass locally, then CI blows up because faker.number.int() generated a negative value that fails your .positive() constraint. The mock was lying the whole time.
I built zodmint to fix this. You pass a Zod schema in, you get a valid value out, guaranteed to pass schema.safeParse(output).success === true. No faker, no hand-written factories.
npm install zodmint
Basic usage:
const UserSchema = z.object({
id: z.uuid(),
email: z.string().email(),
age: z.number().int().min(18).max(99),
role: z.enum(["admin", "user", "guest"]),
});
mock(UserSchema);
// { id: 'b48653da-...', email: '*Emails are not allowed*', age: 41, role: 'admin' }
It also has:
mockFactory() with named states, afterBuild hook, and extend()
- Seeded generation (same seed = same output, great for snapshots)
- Edge mode (boundary values for stress testing)
- Custom matchers and a plugin system for domain-specific values
- Full support for
z.union, z.discriminatedUnion, z.intersection, z.lazy, z.refine, and more
Got some downloads in the first 24h without posting anywhere which surprised me. Would love feedback from people actually using it.