Skip to main content

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
TempInbox tests the real path. Each test run gets a unique address so parallel runs never collide.

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

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

30 seconds is usually enough for local/staging environments. For external SMTP in CI, use 60 seconds.
2–3 second intervals avoid rate limiting. The TempInbox API caches mail lists for 60 seconds at offset=0.
Call DELETE /api/delete_address in afterAll to keep inboxes tidy, though it’s not strictly required since addresses don’t expire.