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

Playwright Email Tests Need a Cleanup Contract

说明与用途

在 Playwright 中实施邮箱所有权合同消除了测试的不可预测性,确保了明确的租赁、令牌验证和清理,并提供可观察的诊断和错误分类。

问题

Email-based end‑to‑end tests become flaky because tests share a mailbox and fail to clean up, leading to stale or cross‑run messages.

结果

Implementing a mailbox ownership contract reduces flaky email tests, provides observable cleanup, and enables precise failure classification (stale-message, cross-run-collision, etc.).

工作流

  • 1. Test leases a mailbox with owner, runId, and lease timestamp.
  • 2. Test performs signup using the leased address.
  • 3. Test waits for a message containing a unique token after the lease time.
  • 4. Test asserts message content and releases the mailbox in a finally block.
  • 5. Server‑side reaper expires abandoned leases; CI publishes lease statistics.

证据

Email-based end-to-end tests often look flaky for the wrong reason. A signup test creates a user, waits for a verification message, and sometimes finds an email that belongs to a previous run.

来源

A reliable fixture should answer four questions before the browser opens the signup page: Who owns it? What can be read? How long can it live? Who cleans it?

来源

Use a fixture that records its state and always attempts release in teardown.

来源

If the browser process is killed, teardown may never run. The mailbox service needs a lease expiry and a reaper, and the CI job should publish counts for active, released, and expired leases.

来源

  • 记录日期: 2026-10-23T00:26:19.499Z