·5 min read
Testing without mocking fetch by hand, again
The mock client swaps in for your real one with the same method signatures, so your components and tests don't know or care the network isn't real.
3 posts
The mock client swaps in for your real one with the same method signatures, so your components and tests don't know or care the network isn't real.
My logger read the active OpenTelemetry span off globalThis. It returned null every single time, and the unit test still passed. Here is the real fix, tested.
Set up Vitest with jsdom and globals, then test three layers: a Zod schema, a React form with Testing Library, and a serverless handler by mocking the Resend constructor.