import { defineConfig, devices } from "@playwright/test" /** * Two projects with very different requirements: * * unit — pure logic (rate limiting, SSRF guard, upload validation, API-key * hashing, crypto, plan limits). No browser, no database, no network. * Runs anywhere, including CI on a bare container, in about a second. * * e2e — real browser against a running app. Needs DATABASE_URL to point at a * migrated Postgres, so it is NOT part of the default run. Enable with * `npm run test:e2e` once a database is available. * * `npm test` runs the unit project only, so a missing database can never make * the default test command fail for the wrong reason. */ export default defineConfig({ testDir: "./tests", fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, reporter: process.env.CI ? [["github"], ["list"]] : [["list"]], projects: [ { name: "unit", testDir: "./tests/unit", use: {}, }, { name: "e2e", testDir: "./tests/e2e", use: { ...devices["Desktop Chrome"], baseURL: process.env.E2E_BASE_URL ?? "http://127.0.0.1:3000", trace: "on-first-retry", }, }, ], // Only started for the e2e project; `npm test` (unit) never boots the app. ...(process.env.E2E === "1" ? { webServer: { command: "npm run start", url: process.env.E2E_BASE_URL ?? "http://127.0.0.1:3000", reuseExistingServer: !process.env.CI, timeout: 120_000, }, } : {}), })