import { fileURLToPath } from "node:url"; import { defineConfig, devices } from "@playwright/test"; export default defineConfig({ testDir: "./tests/visual", forbidOnly: true, snapshotDir: "./tests/visual/__snapshots__", outputDir: "./artifacts/tests/visual/results", reporter: [ ["list"], [ "html", { outputFolder: "./artifacts/tests/visual/report", open: "never" }, ], ["junit", { outputFile: "./artifacts/tests/visual/results.xml" }], ], expect: { toHaveScreenshot: { animations: "disabled", caret: "hide", maxDiffPixelRatio: 0.002, scale: "css", }, }, use: { ...devices["Desktop Chrome"], baseURL: "http://127.0.0.1:4174", colorScheme: "light", locale: "en-US", trace: "retain-on-failure", launchOptions: { // 11-02. Chromium sees only the fonts the goldens were captured with, // whatever the host or an outer FONTCONFIG_FILE says. The // `visual-fonts` project checks them before any screenshot. env: { ...process.env, FONTCONFIG_FILE: fileURLToPath( new URL("./tests/visual/fonts.conf", import.meta.url), ), }, }, }, webServer: { command: "corepack pnpm build && corepack pnpm preview --host 127.0.0.1 --port 4174", url: "http://127.0.0.1:4174", reuseExistingServer: false, }, projects: [ { name: "visual-fonts", testMatch: /fonts\.setup\.ts$/ }, { name: "chromium-visual", dependencies: ["visual-fonts"] }, ], });