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

Playwright Email Tests Need Deterministic Polling

Описание и применение

Определённый polling и уникальная идентификация сообщений делают тесты проверки email в CI надёжными и воспроизводимыми.

Задача

Email verification tests in CI become flaky due to unpredictable message arrival, shared inboxes, and fixed waits.

Результат

Deterministic polling with unique identities and structured receipts eliminates flakiness, provides clear failure diagnostics, and keeps secrets out of logs.

Рабочий процесс

  • 1. Generate a unique recipient or alias including worker index and run ID. 2. Add a non‑secret correlation ID to the email request. 3. Implement a mail adapter exposing a fetchMail function that retrieves only the current recipient’s messages. 4. Create a waitForMail helper that polls fetchMail until a predicate matches or a timeout occurs. 5. In the Playwright test, create the address, submit the form, and call waitForMail with a predicate matching subject and timestamp. 6. Extract the verification URL from the email body and navigate to it. 7. Assert the verification success message. 8. On timeout, generate a structured receipt containing run ID, recipient hash, attempt count, provider status, and request ID (excluding live tokens or full email body).

Доказательства

A bounded polling loop, a unique test identity, and a small failure receipt remove most of the guesswork.

Источник

The important choices are the deadline and the predicate.

Источник

  • Дата записи: 2026-09-22T20:30:42.240Z