Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

1.7 KB
Raw Blame

E2E Tests (Playwright)

Prerequisites

  1. Install Chromium (one-time):

    pnpm --filter web exec playwright install chromium
    
  2. Start MailHog (used for email verification during signup):

    docker-compose -f apps/web/docker-compose.yml up -d mailhog
    
  3. Set environment variables in apps/web/.env:

    # SMTP must point to MailHog — signup tests read OTP emails from it
    SMTP_HOST=localhost
    SMTP_PORT=1025
    
    # RESEND_API_KEY must NOT be set, otherwise emails go to Resend instead of MailHog
    

    Signup tests generate a fresh user each run via MailHog email verification.

API tests

API specs under playwright/api use a Bearer token. globalSetup upserts a dedicated user, workspace, and token into playwright/.auth/api.json before any project runs. No MailHog or browser auth required.

pnpm --filter web test:e2e --project=api
pnpm --filter web test:e2e --project=api playwright/api/tags/tags.spec.ts
pnpm --filter web test:e2e --project=api playwright/api/tags/tags.spec.ts -g "POST /tags"

-g / --grep matches the test title (regex). Combine with a file path to narrow further.

Locators

UI specs locate controls with page.getByTestId and IDs from lib/e2e/test-ids.ts, not button labels or headings. That stays stable when copy changes and when i18n lands. Form fields can still use input[name]. Sonner toasts used as assertions set the same ID via the toast testId option.

Running tests

Make sure the dev server is running first (pnpm dev), then:

# Headless (default)
pnpm --filter web test:e2e

# With browser visible
pnpm --filter web test:e2e:headed

# Interactive UI mode
pnpm --filter web test:e2e:ui