DEV Community

Qasim Muhammad
Qasim Muhammad

Posted on

E2E Email Testing with Playwright and Cypress — No Gmail Credentials Required

Your Playwright test clicks "Reset Password." An email gets sent. Now what?

Most teams fake this with mocked SMTP or MailHog. Tests pass locally but break in staging because the email never actually arrived. There's a better way.

Create a Real Test Inbox

brew install nylas/nylas-cli/nylas
nylas init
nylas inbound create e2e-test
Enter fullscreen mode Exit fullscreen mode

nylas inbound create provisions a managed email address that receives real email. No MX records. No mail server.

Poll for Messages in Your Test

nylas inbound messages checks for new mail:

nylas inbound messages inbox_abc123 --unread --json --limit 1
Enter fullscreen mode Exit fullscreen mode

Parse the JSON output to extract reset links, verification codes, or confirmation emails.

Monitor in Real Time

nylas inbound monitor streams messages as they arrive:

nylas inbound monitor inbox_abc123 --tunnel cloudflared
Enter fullscreen mode Exit fullscreen mode

Extract OTP Codes

Testing two-factor auth? nylas workflow otp list extracts one-time passwords:

nylas workflow otp list --limit 1
Enter fullscreen mode Exit fullscreen mode

List All Test Inboxes

nylas inbound list shows your managed addresses:

nylas inbound list --json
Enter fullscreen mode Exit fullscreen mode

Why Not MailHog?

MailHog intercepts SMTP locally — your app must be configured to send through it. Nylas Inbound addresses receive email through real infrastructure. If it arrives here, it'll arrive in Gmail too.

CI Integration

- name: Install Nylas CLI
  run: curl -fsSL https://cli.nylas.com/install.sh | bash
- name: Run E2E tests
  env:
    NYLAS_API_KEY: ${{ secrets.NYLAS_API_KEY }}
  run: |
    nylas auth config --api-key $NYLAS_API_KEY
    npx playwright test
Enter fullscreen mode Exit fullscreen mode

Webhook Testing

nylas webhook test send fires test events:

nylas webhook test send https://staging.myapp.com/hooks/email
Enter fullscreen mode Exit fullscreen mode

nylas webhook server starts a local receiver:

nylas webhook server --port 4000
Enter fullscreen mode Exit fullscreen mode

All commands: Nylas CLI Command Reference

Get started: brew install nylas/nylas-cli/nylasother install methods

Top comments (0)