I got tired of faker mocks silently breaking my tests, so I built zodmint

I got tired of faker mocks silently breaking my tests, so I built zodmint

posted Originally published at gonll.hashnode.dev 1 min read

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.

More Posts

TypeScript Complexity Has Finally Reached the Point of Total Absurdity

Karol Modelskiverified - Apr 23

Everyone says DeepSeek is cheaper, but I got tired of guessing the exact math. So I built a calculat

abarth23 - Apr 27

5 Web Dev Pitfalls That Are Silently Killing Your Projects (With Real Fixes)

Dharanidharan - Mar 3

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Breaking the AI Data Bottleneck: How Hammerspace's AI Data Platform Eliminates Migration Nightmares

Tom Smithverified - Mar 16
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

4 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!