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

Playwright Email Fixtures Need Ownership Checks

说明与用途

通过生成唯一运行令牌、按令牌过滤收件箱邮件、按ID验证邮件并断言链接主机/路径,Playwright 邮件测试变得可靠。

问题

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

结果

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

工作流

  • 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

证据

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.

来源

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

来源

  • 记录日期: 2026-09-21T16:00:12.516Z