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

Playwright Email Fixtures Need Ownership Checks

Description and use

Playwright email tests become reliable by generating a unique run token, filtering inbox messages by it, validating the message by ID, and asserting the link host/path.

Problem

Email verification tests often fail unpredictably because the test may click a stale or wrong email link, leading to flaky results.

Outcome

Tests become deterministic and failures are traceable to specific email messages, improving CI reliability and debugging speed.

Workflow

  • Generate a unique run token and email address at test start
  • Pass the address to the application under test
  • Record fixture facts (address, run token, worker, action) before polling
  • Poll the inbox: list messages to the address
  • Find the owned message whose subject includes the run token and matches other criteria
  • Return the message ID or null
  • Use Playwright's expect.poll to wait for the message ID within a timeout
  • Fetch the message by ID after polling
  • Validate the verification link host and path
  • Navigate to the link if valid
  • Log a redacted diagnostic receipt
  • Cleanup mailbox after test
  • Repeat for retries, comparing receipts for diagnosis

Evidence

Generate a unique address or mailbox identifier at the beginning of the test. Keep the value in the test's run context and pass it explicitly to the application.

Source

The polling loop should separate retrieval from validation. Retrieval asks whether a candidate exists. Validation proves that it is the right candidate.

Source

  • Record date: 2026-09-21T16:00:12.516Z