import { defineConfig, devices } from "@playwright/test"; import { AUTH_STATE_PATH, E2E_AUTH_SECRET, E2E_BASE_URL, } from "./e2e/support/environment"; const externalServer = Boolean(process.env.E2E_BASE_URL); const storageState = process.env.E2E_STORAGE_STATE || AUTH_STATE_PATH; export default defineConfig({ testDir: "./e2e", fullyParallel: true, forbidOnly: Boolean(process.env.CI), retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : undefined, expect: { timeout: 30_000 }, reporter: process.env.CI ? [["line"], ["html", { open: "never" }]] : [["list"], ["html", { open: "never" }]], outputDir: "test-results", globalSetup: "./e2e/globalSetup.ts", use: { baseURL: E2E_BASE_URL, locale: "zh-CN", timezoneId: "Asia/Shanghai", launchOptions: process.env.E2E_CHROMIUM_PATH ? { executablePath: process.env.E2E_CHROMIUM_PATH } : undefined, trace: "retain-on-failure", screenshot: "only-on-failure", video: "retain-on-failure", }, projects: [ { name: "chromium-public", testMatch: /unauthenticated\.spec\.ts/, use: { ...devices["Desktop Chrome"] }, }, { name: "chromium-authenticated", testIgnore: /unauthenticated\.spec\.ts/, use: { ...devices["Desktop Chrome"], storageState, }, }, ], webServer: externalServer ? undefined : { command: "npm run runtime:config && npm run build && npm run e2e:serve", url: E2E_BASE_URL, reuseExistingServer: false, timeout: 120_000, env: { NEXTAUTH_URL: E2E_BASE_URL, NEXTAUTH_SECRET: E2E_AUTH_SECRET, KEYCLOAK_CLIENT_ID: "tjwater-e2e", KEYCLOAK_CLIENT_SECRET: "tjwater-e2e", KEYCLOAK_ISSUER: "http://127.0.0.1:8180/realms/tjwater-e2e", }, }, });