docs: add a guide for testing emails with Resend (ENG-1577)

Merged
SA
2d ago
+500-3

What

  • A "Test emails with Resend" page (/test-emails-resend) in the "Guides" group of the docs sidebar. The page shows a test that signs up with a Resend test address, then reads the sent email with the Resend SDK. It also shows how to read received email with emails.receiving.
  • A hand-run Resend suite in the testbed: pnpm --filter @e2e-dev/testbed test:resend.

Why

Users who test sign-up or password-reset flows need to read the email their app sends. This page shows how to do it with Resend's own SDK.

How it works

  1. docs/docs.json adds the page to the "Guides" group, after the AgentMail guide. The page sits at the top level as docs/test-emails-resend.mdx, next to docs/test-emails.mdx.
  2. The code on the page lives in docs/examples/resend/. The docs typecheck covers it, and scripts/check-docs-examples.ts maps each file to the page, so the page copy can't drift. docs/package.json adds resend@6.40.1 for the typecheck.
  3. The example test (docs/examples/resend/tests/signup.e2e.ts) signs up with delivered+<uuid>@resend.dev. It waits in toPass() for that email to show up in emails.list() as delivered, then checks its subject and HTML with emails.get(). Resend calls return { data, error }, so the test checks error after each one.
  4. The config passes RESEND_API_KEY to the app with inheritEnv and registers it with registerProviderKey, so e2e redacts it. The guide uses one full-access key for both the app and the test on purpose. That keeps the setup simple. The cost is that the app gets more access than sending needs.
  5. emails.list() has no recipient filter and returns at most 100 emails per page. The Limits section tells readers to run against a dedicated Resend team so other email doesn't push the test's email off the first page.
  6. apps/testbed/e2e.resend.config.ts runs app/resend-signup.mjs, a sign-up page that sends through the real Resend API. When Resend refuses a send or the request fails, the page shows the reason with a 502 status, and the app keeps running. tests-resend/signup.e2e.ts checks a delivered address, a bounced address, and a receiving-domain address. The receiving test skips unless RESEND_RECEIVING_DOMAIN and a verified RESEND_FROM are set. The default testbed config doesn't pick up tests-resend/, so CI never runs it. .fallowrc.json lists the app as an entry, and the README documents the variables.

Choices a fresh-context review questioned that I kept:

  • The page is a tutorial in the inclusive "we" voice, with an "In this guide, we ..." sentence and an "Installation" heading. The page owner chose this voice, so the authoring-docs rules that say otherwise don't apply here.
  • The vendor logo and overview card rules cover integrations, CI services and migration guides. A guide is none of those, so it has no logo or card.

Verified

Ran it locally: yes

  • pnpm check, pnpm test and pnpm --filter @e2e-dev/testbed test pass on this change.
  • The testbed Resend suite, run against the real Resend API:
 ✓ |web| tests-resend/signup.e2e.ts > a welcome email reaches a delivered test address 2.63s
 ✓ |web| tests-resend/signup.e2e.ts > a welcome email to a bounced test address bounces 1.41s
 ↓ |web| tests-resend/signup.e2e.ts > a welcome email arrives at the receiving domain [Set RESEND_RECEIVING_DOMAIN and a verified RESEND_FROM to send real email.]
 Tests  2 passed | 1 skipped (3)
  • The receiving test hasn't been run on the head commit, because it needs a receiving domain that wasn't set up in this environment.
  • I didn't capture screenshots of the rendered page because there's no local docs renderer. The docs preview deploy on this PR shows it.
  • Shortening pass: the page is new, at 172 lines. It doesn't say a fact twice, so I made no cuts.

Summary by CodeRabbit

  • New Features
    • Added Resend examples for verifying signup email delivery and bounce events, with optional incoming-email checks.
    • Added a signup testbed that can send up to three real emails through Resend and display an inbox-check message after a successful signup.
  • Documentation
    • Added a Resend guide covering setup, sent and received email checks, test addresses, and API limits.
    • Added instructions for running the live test suite and configuring the required environment variables.