playwright.config.ts

2.5 KB · raw

1import { defineConfig } from "@playwright/test";2import { fileURLToPath } from "url";3import { dirname, join } from "path";45const __filename = fileURLToPath(import.meta.url);6const __dirname = dirname(__filename);7const EXTENSION_PATH = join(__dirname, "dist-chrome");89const CI = process.env.CI === "true" || process.env.PEACH_RELEASE_BROWSER_GATE === "1";1011export default defineConfig({12  testDir: "./tests",13  timeout: 30_000,14  use: {15    headless: false,16    viewport: { width: 320, height: 600 },17    trace: CI ? "retain-on-failure" : "off",18    screenshot: CI ? "only-on-failure" : "off",19  },20  projects: [21    {22      name: "peach-extension",23      use: {24        launchOptions: {25          args: [26            `--disable-extensions-except=${EXTENSION_PATH}`,27            `--load-extension=${EXTENSION_PATH}`,28            `--no-sandbox`,29            `--disable-gpu`,30            `--disable-dev-shm-usage`,31          ],32        },33      },34      testMatch: "**/*.spec.ts",35      testIgnore: /security-sentinels\.spec\.ts/,36    },37    // PB-26-210: mandatory Chrome release browser gate.38    // Headless, deterministic timeouts, artifact capture on failure.39    // Runs security sentinels for PB-26-201 (authorization) and40    // PB-26-203 (session storage isolation).41    {42      name: "chrome-release",43      use: {44        headless: true,45        launchOptions: {46          executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,47          args: [48            `--disable-extensions-except=${EXTENSION_PATH}`,49            `--load-extension=${EXTENSION_PATH}`,50            `--no-sandbox`,51            `--disable-gpu`,52            `--disable-dev-shm-usage`,53          ],54        },55      },56      testMatch: /security-sentinels\.spec\.ts/,57      timeout: 120_000,58      retries: 0,59    },60    // Firefox release uses software rendering and disabled content sandboxes61    // because the CI host cannot map the hardware compositor.62    {63      name: "firefox-release",64      browserName: "firefox",65      use: {66        headless: true,67        launchOptions: {68          env: {69            ...process.env,70            MOZ_HEADLESS: "1",71            MOZ_DISABLE_CONTENT_SANDBOX: "1",72            MOZ_DISABLE_RDD_SANDBOX: "1",73            LIBGL_ALWAYS_SOFTWARE: "1",74          },75        },76        firefoxUserPrefs: {77          "gfx.webrender.all": false,78          "gfx.webrender.software": false,79          "media.hardware-video-decoding.force-enabled": false,80        },81      },82      testMatch: /security-sentinels\.spec\.ts/,83      timeout: 120_000,84      retries: 0,85    },86  ],87});