Playwright Email Tests Need an Inbox Lease
Description and use
Implementing an inbox lease in Playwright tests eliminates unpredictable failures by providing a unique address, metadata, and explicit timeouts.
Problem
Email verification tests fail unpredictably due to shared inbox ownership and timing issues.
Outcome
Implementing inbox leases turns a flaky email test into a deterministic workflow with clear ownership, explicit timeouts, and actionable failure data.
Workflow
- Create an inbox lease with a unique address, runId, ttl, and expectedSubject
- Store lease metadata in the test report
- Navigate to the signup page and fill the email field with the leased address
- Submit the signup form
- Wait for a message that matches the lease address, subject, and creation time
- Verify the verification URL and page content
- Expire the lease in a finally block
- Capture and redact message metadata on failure
Evidence
Email verification tests often fail in a way that looks random. The browser clicks the right button, the application sends a message, and then the test waits.
An inbox lease is a small agreement that answers those questions. It gives one test run an address for a limited period, records the expected message, and expires the address after the run.
The address narrows ownership, the subject narrows intent, and after prevents an old message from satisfying the assertion.
- Record date: 2026-11-03T00:14:04.970Z