<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged mock</title>
<link>https://coderlegion.com/tag/mock</link>
<description>Powered by Question2Answer</description>
<item>
<title>I got tired of faker mocks silently breaking my tests, so I built zodmint</title>
<link>https://coderlegion.com/18930/i-got-tired-of-faker-mocks-silently-breaking-my-tests-so-i-built-zodmint</link>
<description>&lt;p&gt;You know the pattern: you write a factory with faker, tests pass locally, then CI blows up because &lt;code&gt;faker.number.int()&lt;/code&gt; generated a negative value that fails your &lt;code&gt;.positive()&lt;/code&gt; constraint. The mock was lying the whole time.&lt;/p&gt;
&lt;p&gt;I built zodmint to fix this. You pass a Zod schema in, you get a valid value out, guaranteed to pass &lt;code&gt;schema.safeParse(output).success === true&lt;/code&gt;. No faker, no hand-written factories.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npm install zodmint
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Basic usage:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;const UserSchema = z.object({
  id: z.uuid(),
  email: z.string().email(),
  age: z.number().int().min(18).max(99),
  role: z.enum([&quot;admin&quot;, &quot;user&quot;, &quot;guest&quot;]),
});

mock(UserSchema);
// { id: 'b48653da-...', email: '*Emails are not allowed*', age: 41, role: 'admin' }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It also has:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mockFactory()&lt;/code&gt; with named states, &lt;code&gt;afterBuild&lt;/code&gt; hook, and &lt;code&gt;extend()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Seeded generation (same seed = same output, great for snapshots)&lt;/li&gt;
&lt;li&gt;Edge mode (boundary values for stress testing)&lt;/li&gt;
&lt;li&gt;Custom matchers and a plugin system for domain-specific values&lt;/li&gt;
&lt;li&gt;Full support for &lt;code&gt;z.union&lt;/code&gt;, &lt;code&gt;z.discriminatedUnion&lt;/code&gt;, &lt;code&gt;z.intersection&lt;/code&gt;, &lt;code&gt;z.lazy&lt;/code&gt;, &lt;code&gt;z.refine&lt;/code&gt;, and more&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Got some downloads in the first 24h without posting anywhere which surprised me. Would love feedback from people actually using it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;npm: &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.npmjs.com/package/zodmint&quot;&gt;https://www.npmjs.com/package/zodmint&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/gonll/zodmint&quot;&gt;https://github.com/gonll/zodmint&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/18930/i-got-tired-of-faker-mocks-silently-breaking-my-tests-so-i-built-zodmint</guid>
<pubDate>Mon, 25 May 2026 22:44:32 +0000</pubDate>
</item>
</channel>
</rss>