Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Playwright Email Tests Need a Message Claim

Description and use

In Playwright, email verification tests become reliable by having each test claim a specific message using a unique run identifier and timestamp before asserting, ensuring deterministic behavior and clear diagnostics.

Problem

Email verification tests often fail due to identity correlation problems rather than timing, causing flaky CI results.

Outcome

Implementing a message claim pattern eliminates flaky email verification tests by ensuring each test operates on a unique, verifiable message.

Workflow

  • Generate a unique runId and email address before sending the signup request.
  • Send the signup request and capture the request start time.
  • Poll the inbox with a deadline, filtering messages by recipient, runId in subject, and receivedAt after request start.
  • Return a MessageClaim object containing runId, recipient, messageId, and receivedAt.
  • Attach a redacted receipt (email-claim.json) to the test for evidence.
  • Fetch the claimed message by ID and assert the verification link.
  • Use a shared fixture to encapsulate polling, backoff, and cleanup.

Evidence

Email verification tests often fail for a reason that looks like timing, but is really identity.

Source

The test receives a message, finds a token, and assumes that token belongs to the current run.

Source

Before sending the signup request, create a run identifier and save the time at which the request starts.

Source

The polling operation should return a MessageClaim, not just a body string.

Source

After claiming a message, save a small redacted receipt as a test attachment.

Source

  • Record date: 2026-10-11T09:56:11.752Z