Why use a real inbox in E2E tests?
Test fixtures and mocked emails skip the actual SMTP delivery path — meaning they miss:- Rendering bugs in email templates
- Spam filter rejections
- SMTP misconfiguration
- Delays caused by delivery queuing
Setup
No package install needed — the TempInbox API is a plain HTTP REST API.Helper: tempmail.ts
Create a shared helper that manages address creation and polling:
tempmail.ts
Example: OTP verification flow
tests/otp-signup.spec.ts
Example: Magic link flow
tests/magic-link.spec.ts
Parallel test safety
Each test creates its own unique address — no shared state, no race conditions.playwright.config.ts
Tips
Set a realistic poll timeout
Set a realistic poll timeout
30 seconds is usually enough for local/staging environments. For external SMTP in CI, use 60 seconds.
Don't poll too fast
Don't poll too fast
2–3 second intervals avoid rate limiting. The TempInbox API caches mail lists for 60 seconds at offset=0.
Clean up after tests
Clean up after tests
Call
DELETE /api/delete_address in afterAll to keep inboxes tidy, though it’s not strictly required since addresses don’t expire.Related reading
- Disposable Email in Playwright and Cypress: E2E — broader E2E patterns and pitfalls
- Email for Testing: A Practical QA Playbook — when to use real inboxes vs mocks
- Cypress guide — the same flow using Cypress tasks