Testing Emails

Validate @nebutra/email with no-key contract tests, local preview checks, and Resend test delivery.

Test email changes at three levels: package contract, local preview artifacts, and safe provider delivery.

Never send real emails in test or CI environments. Package tests and preview checks do not require RESEND_API_KEY.

Package contract

Run the package tests after changing sender helpers, catalog entries, preview filenames, or import-time behavior:

pnpm --filter @nebutra/email test
pnpm --filter @nebutra/email typecheck

The contract test verifies that every EMAIL_TEMPLATE_CATALOG entry has a public send helper and a matching preview artifact.

Local preview artifacts

Use the dedicated preview workspace:

pnpm mail:check
pnpm mail:export

mail:check fails when a catalog entry is missing from apps/mail-preview/dist. mail:export regenerates dist/index.html and dist/preview-manifest.json from the package-owned catalog.

Resend test delivery

Resend test keys accept API calls and show logs without delivering to real recipients.

# .env.local — never commit this file
RESEND_API_KEY=re_test_...
EMAIL_FROM=Nebutra <[email protected]>
import { sendMagicLinkEmail } from "@nebutra/email";

await sendMagicLinkEmail({
  to: "[email protected]",
  magicLinkUrl: "https://app.nebutra.com/login/magic-link/test",
});

[email protected] is Resend's test address for successful delivery logs.

CI checklist

  • pnpm --filter @nebutra/email test
  • pnpm --filter @nebutra/email typecheck
  • pnpm mail:check
  • pnpm mail:export when preview index/manifest output matters
  • Production delivery uses a verified sending domain and production key

How is this guide?

Edit on GitHub

Last updated on

On this page