← Back to list

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

You know the pattern: you write a factory with faker, tests pass locally, then CI blows up because `faker.number.int()` generated a…

Gonzalo Herrera Llobeta · 2026-05-25 21:36 · 1 claps · 0.9 min read
#typescript #javascript #zod #mock #faker-js
Open on Medium ↗
Wiki topics: 🌐 · Web Development

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

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: ‘isabella89@fixture.dev’, 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.


메타데이터
post_id
9e4b5cee37e7
slug
i-got-tired-of-faker-mocks-silently-breaking-my-tests-so-i-built-zodmint-9e4b5cee37e7
url
https://medium.com/@gonzalohll/i-got-tired-of-faker-mocks-silently-breaking-my-tests-so-i-built-zodmint-9e4b5cee37e7
canonical_url
https://medium.com/@gonzalohll/i-got-tired-of-faker-mocks-silently-breaking-my-tests-so-i-built-zodmint-9e4b5cee37e7
author_url
https://medium.com/@gonzalohll
status
ok
fetched_at
2026-06-14 11:28:49