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

Playwright Email Tests Need a Failure Receipt

说明与用途

在 Playwright 邮件测试中添加结构化失败记录,将模糊的超时错误转化为可操作的诊断信息,减少调试时间并提升可靠性。

问题

Email verification tests often fail with vague timeouts, making diagnosis hard and costly.

结果

Adding structured failure receipts transforms vague timeout failures into actionable diagnostics, reducing debugging time and improving test reliability.

工作流

  • 1. Create a unique mailbox or correlation ID for each test.
  • 2. Initialize an EmailFailureReceipt object before test actions.
  • 3. After each major boundary (signup, delivery, matching, verification), update receipt.failureStage and record relevant data (status codes, poll counts, message metadata).
  • 4. In test.afterEach hook, if test failed, attach the receipt JSON to Playwright’s testInfo using testInfo.attach().
  • 5. In CI, configure to capture receipts and screenshots only on failure, mask sensitive data, and keep separate timeouts for delivery and browser assertions.
  • 6. Use helper functions for each boundary that throw errors with stage info and update the receipt accordingly.

证据

Write the receipt in an afterEach hook only when the test fails. Attach it with Playwright’s test information object, so the report and CI artifact remain connected to the original test.

来源

Create a fresh inbox identity per test or per isolated worker.

来源

  • 记录日期: 2026-09-19T20:15:27.421Z