Skip to main content

E2E Testing with Playwright

When building authentication flows, password resets, or transactional receipts, you need reliable end-to-end tests to verify that emails are correctly generated and received.

Strategy: Test via Inbound Webhooks or API Querying

Instead of attempting to log into a real Gmail or Outlook account with browser automation:
  1. Generate a unique test address per test run (e.g. test-${Date.now()}@yourdomain.com).
  2. Trigger the application action in your Playwright test (e.g. “Click Sign Up”).
  3. Use Mailofly’s Emails or Received API to query for the incoming email payload.
  4. Extract the magic link or OTP token and continue the browser test.

Example Playwright Test

tests/auth.spec.ts