sincecutoff.com
← all changes

createTestHarness dispatches email handlers

Introduced 2026-07-30 · score 0.98

HOW TO USE IT

When testing a Worker's `email()` handler with Wrangler 4.116.0, call `server.getWorker().email({ from, to, raw })` and inspect the returned outcome, rejection reason, forwards, and replies.

const result = await server.getWorker().email({ from: "sender@example.com", to: "inbox@example.com", raw: ["From: Sender <sender@example.com>", "To: Inbox <inbox@example.com>", "Message-ID: <test@example.com>", "Subject: Test email", "", "Hello from the test harness"].join("\r\n") }); expect(result).toMatchObject({ outcome: "ok", forwards: [{ recipient: "archive@example.com" }], replies: [{ sender: "inbox@example.com", raw: expect.stringContaining("Thanks for your email") }] });

WHY THIS HELPS

Test a Worker's `email()` handler and inspect its outcome, rejection reason, forwarded messages, and replies.

REQUIREMENTS AND LIMITATIONS

  • Version: 4.116.0
  • from (required): Sender email address for the dispatched message.
  • to (required): Recipient email address for the dispatched message.
  • raw (required): Raw email content, supplied as a string.
  • Prerequisite: Use Wrangler 4.116.0 or later, where the release note adds email dispatch support to createTestHarness.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card