Menu

Testing email flows in CI without sending email
📰

Testing email flows in CI without sending email

DEV Community: cicd·Volanea·13 days ago
#KXzKFVA7
#devtocicd#devto#dev#real#send
Reading 0:00
15s threshold

Email is usually the least tested part of a product because the test would send a real message to a real inbox. The workaround is a test doubles pattern that is easy to get wrong.

Assert on the intent, not the transport

Most suites mock the email client and assert that send was called. That passes while the template is broken. The useful assertion is on the rendered output: subject, recipient, and the presence of the token or link that the flow depends on.

Render in the test

Render the template with the same code path as production, then check the HTML and the text part both contain the expected URL. This catches the failure that matters most: a link that lost its base URL and now points at localhost.

Keep one real send per release

Mocks cannot catch DNS, authentication, or provider rejection.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.