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

Playwright Email Tests Need Lease Expiry

说明与用途

Playwright 邮件测试引入租赁机制,记录所有者、创建、过期和释放时间,消除因旧消息和工作器冲突导致的不可预测失败。

问题

Email test fixtures that live indefinitely cause flaky tests due to stale messages, worker collisions, expired tokens, and cleanup races.

结果

Tests become deterministic; failures are attributed to lease expiry or worker collision rather than random message timing.

工作流

  • 1. Define a LeasedInbox type with address, owner, expiresAt, assertUsable, and release methods.
  • 2. Extend Playwright’s test fixture to lease an inbox via a mail client, passing owner and ttlMs.
  • 3. In the fixture, create a LeasedInbox object that checks expiry before use and releases the inbox after the test.
  • 4. In tests, call inbox.assertUsable() before and after actions, use inbox.address for form inputs, and wait for messages with a since timestamp.
  • 5. Attach lease metadata to test reports for post‑mortem analysis.

证据

I treat a test inbox like a leased resource. The test claims it, uses it for one bounded scenario, and releases or expires it when the run ends.

来源

A lease gives the fixture four useful facts: owner, createdAt, expiresAt, releasedAt.

来源

I usually find one of four patterns when an email test starts failing after parallelism is added: Old message match, Worker collision, Expired token, Cleanup race.

来源

  • 记录日期: 2026-10-16T21:56:02.615Z