Make Playwright Email Tests Explain Their Waits
说明与用途
Playwright 邮件验证测试经常以通用超时结束,隐藏根本原因。文章提出使用受限探针监视邮箱,记录状态转换、时间戳和诊断信息,并将其存储为 JSON 工件以供后续分析。
问题
Email verification tests in Playwright often fail with a generic timeout error, hiding the root cause of why the message was not found.
结果
The test now reports explicit mailbox states, timestamps, and observed subjects, turning a vague timeout into actionable diagnostics.
工作流
- Allocate a unique inbox address using the inbox client.
- Generate a correlation token and record the trigger timestamp.
- Invoke a bounded probe that polls the inbox at fixed intervals until a deadline.
- Return a ProbeResult indicating matched or timed‑out state and the subjects seen.
- Attach the probe result, address, token, and request ID to the Playwright test as a JSON artifact.
- Use the artifact to correlate browser actions, server logs, and inbox data for debugging.
证据
Email verification tests often fail in a confusing way: the browser is on the right page, the message eventually arrives, and the test still reports only Timeout 30000ms exceeded.
The probe should poll at a fixed interval, stop at a deadline, and return the messages it saw.
Attach the probe result to the Playwright test, along with the allocated address, correlation token, and trigger timestamp.
- 记录日期: 2026-11-01T21:29:14.528Z