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