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

A Tiny Email Fixture Factory for CI

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

Фикстуры электронной почты в CI обеспечивают уникальные, отслеживаемые адреса, ограниченное ожидание сообщений, гарантированную очистку и скрытые артефакты, что делает тесты предсказуемыми и упрощает отладку.

Задача

Tests that rely on email verification become hard to reproduce and interfere with each other when each test creates its own disposable email address, leading to flaky CI runs.

Результат

Tests become deterministic, failures are categorized (message missing, link invalid, address rejected), and debugging focuses on contract steps rather than generic email receipt.

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

  • Create a unique fixture key using runId and testId
  • Call createMailFixture to obtain address, key, waitFor, and dispose functions
  • Use waitFor(subject, timeoutMs) to poll for the expected email within a deadline
  • Extract the verification link from the returned message object
  • Perform the test action (e.g., click link, verify account state)
  • Wrap test logic in try/finally to ensure dispose() is called
  • Record timeout evidence as a test artifact, redacting sensitive data
  • If cleanup fails, report separately from the test assertion

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

Every test gets a unique address or inbox key.

Источник

The factory can expose only three operations: create, wait, and dispose.

Источник

Wrap the fixture in a try/finally block, and make disposal idempotent.

Источник

  • Дата записи: 2026-09-21T10:00:41.192Z