Guide OTP email testing in CI: a practical guide
Email is slow and asynchronous, which is why email tests flake. A few rules make them dependable.
Updated 2026-10-02 · Emailsify
Rules that remove flakiness
- One inbox per test. Never share addresses between tests.
- Wait for the message, never sleep for a fixed time.
- Set a timeout that reflects real delivery times, then fail with a useful message.
- Filter by sender or subject so stale mail cannot match.
- Assert on the extracted code or link, not on the whole email.
What to log
- The generated address.
- The time you triggered the email and the time it arrived.
- The subject of the message you matched.
Frequently asked questions
What timeout should I use?
Start with 30 to 60 seconds and tune from your measured delivery times.