playwright.config.ts
import { defineConfig, devices } from "@playwright/test";
// Runners sharing one host run e2e side by side: each gets its own ports (E2E_PORT_OFFSET, set per runner in CI).
const OFFSET = Number(process.env.E2E_PORT_OFFSET ?? 0);
const APP = 4580 + OFFSET;
const MOCK = 4599 + OFFSET;
const WEBKIT_SPECS =
/(webkit|audio-output|audio-gesture|navigation|settings|responsive|now-playing|queue|sticky-bar|sidebar-resize|demo)\.e2e/;
const PHONE_SPECS =
/(webkit|audio-gesture|settings|settings-phone|responsive|now-playing|touch-targets|artists-rail|player-bar-phone)\.e2e/;
process.env.E2E_MOCK_URL = `http://127.0.0.1:${MOCK}`;
export default defineConfig({
testDir: "e2e",
testMatch: "**/*.e2e.ts",
fullyParallel: true,
forbidOnly: !!process.env.CI,
expect: { timeout: process.env.CI ? 10_000 : 5_000 },
retries: process.env.CI ? 1 : 0,
reporter: process.env.CI ? [["github"], ["html", { open: "never" }]] : "list",
use: { baseURL: `http://127.0.0.1:${APP}`, trace: "retain-on-failure" },
projects: [
{ name: "chromium", testIgnore: /lighthouse|webkit/, use: { ...devices["Desktop Chrome"], viewport: { width: 1440, height: 900 } } },
{ name: "webkit", testMatch: WEBKIT_SPECS, use: { ...devices["Desktop Safari"], viewport: { width: 1440, height: 900 } } },
{ name: "phone", testMatch: PHONE_SPECS, use: { ...devices["iPhone 14"] } },
// Alone and last, and one profile at a time: a busy CPU from parallel tests would skew the score.
{ name: "lighthouse", testMatch: /lighthouse/, dependencies: ["chromium"], fullyParallel: false },
],
webServer: [
{
command: "bun test/mock/server.ts",
url: `http://127.0.0.1:${MOCK}/rest/ping`,
env: { MOCK_PORT: String(MOCK) },
},
{
command: "bun scripts/build.ts && ./dist/lodesong",
url: `http://127.0.0.1:${APP}/healthz`,
env: {
PORT: String(APP),
NAVIDROME_URL: `http://127.0.0.1:${MOCK}`,
DATA_DIR: "test-results/data",
UPLOAD_DIR: `${process.cwd()}/test-results/uploads`,
// Every test signs in as the same user: one shared session would have their tabs take over from each other.
ONE_SESSION: "off",
GROQ_API_KEY: "e2e-groq-key",
GROQ_URL: `http://127.0.0.1:${MOCK}/groq`,
LYTERION_URL: `http://127.0.0.1:${MOCK}/lyterion`,
LYTERION_TOKEN: "e2e-lyterion-token-0123456789",
MUSICBRAINZ_URL: `http://127.0.0.1:${MOCK}/musicbrainz`,
LRCLIB_URL: `http://127.0.0.1:${MOCK}/lrclib`,
LYRICS_BACKFILL: "off",
AUDIOMUSE_URL: `http://127.0.0.1:${MOCK}/audiomuse`,
},
timeout: 120_000,
},
],
});