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

Playwright Mail Tests Need a Consumption Ledger

说明与用途

在 Playwright 中实现消费账本可消除误报,确保每个测试验证正确的邮件,并提供更清晰的错误诊断。

问题

Email verification tests can pass for the wrong reason when a shared inbox contains stale messages, retries consume the same message, or parallel workers read the same link, leading to false positives.

结果

The ledger approach reduces stale inbox failures, clarifies failure reasons, and prevents race conditions in parallel test execution.

工作流

  • 1. Generate a unique correlation ID for the test run.
  • 2. Record the mailbox cursor before polling.
  • 3. Poll for new messages using a cursor and a set of seen IDs.
  • 4. When a matching message is found, claim it in the ledger.
  • 5. Extract the verification URL and navigate to it.
  • 6. Mark the message as opened in the ledger.
  • 7. Handle retries and parallel workers by including worker and retry identifiers in the correlation ID.
  • 8. Clean up the ledger even if the test fails.

证据

An email verification test can pass for the wrong reason. A shared inbox may already contain a valid message, a retry may consume the message from the first attempt, or two parallel workers may both read the same link.

来源

The ledger does not need to be a database. For most end-to-end suites, a run-scoped object or JSON attachment is enough.

来源

After the message is found, claim it before opening the link:

来源

  • 记录日期: 2026-10-09T00:56:09.129Z