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

Playwright Email Tests Need a Message Claim

说明与用途

在 Playwright 中,通过在断言之前使用唯一的运行标识符和时间戳声明特定邮件,确保每个测试只处理该邮件,从而使电子邮件验证测试变得可靠。

问题

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

结果

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

工作流

  • 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.

证据

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

来源

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

来源

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

来源

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

来源

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

来源

  • 记录日期: 2026-10-11T09:56:11.752Z