← Use Cases/CI / CD Pipelines

CI / CD Pipelines

Provision a fresh, isolated disposable inbox per test run. Works with GitHub Actions, GitLab CI, CircleCI, and any CI that can run shell commands or Node/Python.

GitHub Actions

Store your API key in Settings → Secrets → FCE_API_KEY, then reference it in your workflow.

yaml
# .github/workflows/e2e.yml
name: E2E Tests

on: [push, pull_request]

jobs:
  e2e:
    runs-on: ubuntu-latest
    env:
      FCE_API_KEY: ${{ secrets.FCE_API_KEY }}

    steps:
      - uses: actions/checkout@v4

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Install dependencies
        run: npm ci

      - name: Install Playwright browsers
        run: npx playwright install --with-deps

      - name: Run E2E tests
        run: npx playwright test
        env:
          FCE_API_KEY: ${{ secrets.FCE_API_KEY }}

Playwright / Jest Setup Helper

Wrap the FreeCustom.Email Node SDK in a reusable helper that you can inject into any test file.

typescript
// helpers/inbox.ts
import { FreecustomEmailClient } from "freecustom-email";

// Ensure FCE_API_KEY is available in your CI environment secrets
export const fce = new FreecustomEmailClient({ apiKey: process.env.FCE_API_KEY! });

export async function createInbox(prefix = "ci"): Promise<string> {
  const inbox = `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2,6)}@ditapi.info`;
  await fce.inboxes.register(inbox);
  return inbox;
}

export async function waitForOtp(inbox: string, timeoutMs = 30_000): Promise<string> {
  // Uses long-polling automatically, handles retries and extraction
  const otp = await fce.otp.waitFor(inbox, { timeoutMs });
  if (!otp) throw new Error("No OTP received within timeout");
  return otp;
}

GitLab CI

yaml
# .gitlab-ci.yml
stages:
  - test

e2e:
  stage: test
  image: mcr.microsoft.com/playwright:v1.44.0-jammy
  variables:
    FCE_API_KEY: $FCE_API_KEY  # set in CI/CD → Variables
  script:
    - npm ci
    - npx playwright test
  artifacts:
    when: always
    paths:
      - playwright-report/
    expire_in: 7 days

CircleCI

yaml
# .circleci/config.yml
version: 2.1

jobs:
  e2e:
    docker:
      - image: mcr.microsoft.com/playwright:v1.44.0-jammy
    environment:
      FCE_API_KEY: $FCE_API_KEY  # set in Project Settings → Environment Variables
    steps:
      - checkout
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test
      - store_artifacts:
          path: playwright-report

workflows:
  test:
    jobs:
      - e2e

pytest fixture (Python)

Provide a fresh inbox as a pytest fixture with automatic teardown using the Python SDK.

python
# conftest.py
import time, os, pytest
from freecustom_email import FreeCustomEmail

# Use sync=True to work easily inside synchronous pytest fixtures
fce = FreeCustomEmail(api_key=os.environ["FCE_API_KEY"], sync=True)

@pytest.fixture
def disposable_inbox():
    """Yields a unique inbox address; registers it before and unregisters after."""
    inbox = f"pytest-{int(time.time())}@ditapi.info"
    fce.inboxes.register(inbox)
    
    yield inbox
    
    # Cleanup after test completes
    fce.inboxes.unregister(inbox)

# --- example test ---
# def test_signup(browser, disposable_inbox):
#     page = browser.new_page()
#     page.goto("https://your-app.com/signup")
#     page.fill('[name="email"]', disposable_inbox)
#     page.fill('[name="password"]', "Test1234!")
#     page.click('[type="submit"]')
#
#     # SDK handles waiting and OTP extraction
#     otp = fce.otp.wait_for(disposable_inbox, timeout_ms=30000)
#     assert otp, "No OTP received"
#
#     page.fill('[name="otp"]', otp)
#     page.click('[data-testid="verify-btn"]')
#     assert "/dashboard" in page.url