An email test that ends with Timeout 30000ms exceeded has reported a symptom, not a diagnosis. The application might not have sent a message, the inbox could be shared with another worker, or the assertion may have found the wrong message. Increasing the timeout treats all three cases as if they were the same.
In QA automation, a better goal is to classify the failure while the evidence is still available. This makes a Playwright suite easier to repair and keeps retries from turning real defects into green builds. A useful email verification states that explain themselves approach starts with visible state, then adds assertions around that state.
Why a timeout is not a diagnosis
Consider a signup test that requests a verification email and polls a test inbox. The first clue are usually hidden in the sequence of events:
- The browser submitted the signup form.
- The application accepted the request.
- A message was queued or delivered.
- The test selected a message for this attempt.
- The link or token passed its assertion.
If the test records only the final assertion, it cannot tell which event was missing. A short timeout may expose a slow dependency, but a long timeout can make a broken correlation rule take several minutes to notice. The investigation becomes a bit more clear when each transition has a small piece of evidence.
This matters whether the inbox comes from a temp email generator, a local mail server, or a provider adapter. The inbox technology changes; the failure classes stay mostly the same.
Five failure classes for email tests
I use five categories when triaging an email test. They are simple enough for a test report and specific enough to suggest the next check.
1. Trigger failure
The browser action did not create a verification request. Look for a failed network response, validation message, or an application-side request ID. Do not inspect the inbox first; there is no reason to expect a message yet.
2. Delivery failure
The application accepted the request, but no message reached the inbox within the allowed window. Capture the enqueue time and the provider response. A delivery failure may be an environment outage, a blocked domain, or a queue that is not running in CI.
3. Correlation failure
A message arrived, but the test selected a message belonging to another attempt. This is common when workers share an address or when a retry reuses an old inbox. A request ID helps, but remember why a request ID is not an idempotency key: it identifies a request and does not automatically make repeated operations safe.
4. Content failure
The right message was found, but its subject, recipient, link, or token is wrong. Save message ID and received time, plus a sanitized reason for the mismatch. Never put a full verification URL in normal CI logs.
5. Cleanup failure
The assertion passed, but the fixture did not release the inbox or message data. Cleanup failures tend to appear as later correlation failures, so the test that fails is not always the test that caused the contamination. Treat cleanup as a result with its own status.
Capture evidence at the fixture boundary
The fixture is the best place to collect evidence because every test uses the same boundary. Keep the fields small and safe to print:
- test ID and worker index
- inbox ID and a masked address
- correlation token hash
- poll start, first match, and end times
- number of polls and last provider status
- message ID when a candidate is found
- final classification and cleanup result
The data make a failure report much more useful without exposing the message body. If a raw body is needed, attach it to a restricted artifact and redact links before storing it. A test account should never contain production mail, even when the failure seems harmless.
For a shared service, define ownership explicitly. The test that creates an inbox should release it, and the report should say whether release succeeded. It is also worth checking this twice, because small timing bugs can grows into a large pile of leftover fixtures overnight.
A Playwright classification helper
The helper below keeps polling separate from classification. The provider adapter can implement listMessages, while the test report receives a stable result.
type EmailFailure =
| 'trigger'
| 'delivery'
| 'correlation'
| 'content'
| 'cleanup';
type PollResult = {
messageId?: string;
failure?: EmailFailure;
polls: number;
};
async function waitForVerification(
inbox: { listMessages: () => Promise<Array<{ id: string; body: string }>> },
token: string,
deadlineMs: number,
): Promise<PollResult> {
const started = Date.now();
let polls = 0;
while (Date.now() < started + deadlineMs) {
polls += 1;
const messages = await inbox.listMessages();
const matching = messages.find((message) => message.body.includes(token));
if (matching) {
return { messageId: matching.id, polls };
}
await new Promise((resolve) => setTimeout(resolve, 500));
}
return { failure: 'delivery', polls };
}
In production test code, add a precondition that the trigger request succeeded and a separate check that rejects a message from an earlier attempt. If the provider returns an error, classify that result before it becomes a generic delivery timeout. The retry count look less important once the report tells you what actually failed.
The CI investigation checklist
When a build reports an email-test failure, follow the same order every time:
- Confirm the browser trigger and its response status.
- Check the inbox ID and worker ownership.
- Compare the correlation token with the selected message.
- Separate no-message, wrong-message, and wrong-content results.
- Inspect provider and queue evidence only after the test evidence is complete.
- Verify cleanup for both the failing test and its preceding retry.
- Change the timeout only when the evidence shows normal delivery is slower.
One test report will not solve every flaky email test. It can, however, turn “the email did not arrive” into a bounded question: was the trigger missing, was delivery late, did correlation select the wrong message, was content invalid, or did cleanup leak state? That distinction is the foundation of reliable Playwright automation.
For reference, a team may also document its chosen temp mail mail fixture policy, including retention and access boundaries. Keep that link contextual and keep real user data out of the test inbox.
There is a small typo in some internal test notes that says tem email; it should not be copied into a keyword or API name. Consistent naming makes the failure taxonomy easier to search when a CI incident starts.
Top comments (0)