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

●2 ●5
calendar_today • schedule1 min read
— Originally published at gonll.hashnode.dev

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.

Want more #javascript & #typescript deep dives?

Join 6,046+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

2 Comments

1 vote
1

More Posts

TypeScript Complexity Has Finally Reached the Point of Total Absurdity

Karol Modelski - Apr 23

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

abarth23 - Apr 27

Cloudflare Blocked My Server, So I Made My Visitors' Browsers Do the Fetching

bryanhamiltondevverified - Nov 15

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

Tom Smithverified - Mar 16

A coach complained, so I built sports academy management software

rahuldk1105 - Oct 26
chevron_left
139 Points • 7 Badges
1Posts
1Comments

Related Jobs

Commenters (This Week)

3 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!