Email Testing with Jest

How to test email flows in Jest using disposable inboxes. Create temp addresses, wait for emails, assert content — all via REST API. Pay per email, no subscription.

Frequently Asked Questions

Can I use the sed.sh Inbox API with Jest?

Yes. Install @sed-sh/sdk and use it directly in any Jest test. The SDK works in any Node.js environment — no special Jest plugin or transform needed.

How do I avoid test flakiness with email timing?

Use a polling loop with a 30-second timeout and 2-second poll interval. Emails via AWS SES arrive in 1–3 seconds in practice. Set jest.setTimeout(60000) globally in jest.config.js.

How do I run email tests in parallel without conflicts?

Create a new inbox per test in beforeEach. Each inbox has a unique @sed.sh email address so parallel test workers never share or interfere with each other's messages.

How much do email tests cost with sed.sh?

$0.0012 per email for the first 5,000. A $10 deposit covers ~8,300 emails — more than enough for a large test suite running in CI every day.

Do I need to mock anything to test emails?

No. Your app sends to a real @sed.sh address and the email arrives on sed.sh's mail servers. You read it via REST API. No mocking, no fake SMTP server, no Mailhog container.

How do I clean up inboxes after tests?

Call deleteInbox(code) in afterEach. Inboxes auto-expire after 30 days anyway, but deleting immediately keeps you within the 100-active-inbox limit per account.