Files
Ferrous-Solitaire/solitaire_server/e2e/playwright.config.js
funman300 5091d1b397 ci(web-e2e): prebuild server so Playwright webServer stops timing out
The web-e2e job has been failing on every run with:

    Error: Timed out waiting 120000ms from config.webServer.

Playwright's `webServer` runs `cargo run -p solitaire_server --quiet` and
waits 120s for /health. The workflow cached only npm — no Rust cache — so each
run cold-compiled the entire server graph (axum/sqlx/reqwest/aws-lc-sys) inside
that 120s window and never came up. The browser tests never executed; the
failure was infra, not a web regression.

Fix the harness so the tests actually run:
- add `Swatinem/rust-cache@v2` to warm the cargo cache across runs
- add a `Prebuild server` step (`SQLX_OFFLINE=true cargo build -p
  solitaire_server`) before Playwright, so `webServer`'s `cargo run` reuses the
  compiled binary and starts in seconds (.sqlx offline cache is committed)
- raise `webServer.timeout` 120s -> 300s as a safety margin for a cold cargo
  cache (e.g. first run after a deps bump)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 12:09:47 -07:00

46 lines
1.5 KiB
JavaScript

const path = require("path");
const { defineConfig, devices } = require("@playwright/test");
const serverPort = 4173;
const repoRoot = path.resolve(__dirname, "../..");
module.exports = defineConfig({
testDir: "./tests",
timeout: 30_000,
expect: {
timeout: 5_000,
},
fullyParallel: false,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [["list"], ["html", { open: "never" }]],
use: {
baseURL: `http://127.0.0.1:${serverPort}`,
trace: "retain-on-failure",
screenshot: "only-on-failure",
video: "retain-on-failure",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
webServer: {
command:
`SQLX_OFFLINE=true ` +
`DATABASE_URL=sqlite://ferrous-solitaire-e2e.db ` +
`JWT_SECRET=ferrous_solitaire_e2e_secret_32_chars_long ` +
`SERVER_PORT=${serverPort} ` +
`cargo run -p solitaire_server --quiet`,
cwd: repoRoot,
url: `http://127.0.0.1:${serverPort}/health`,
// CI prebuilds the server (see web-e2e.yml) so `cargo run` reuses the
// compiled binary and starts in seconds. The generous timeout is a
// safety margin for a cold cargo cache (e.g. first run after a deps
// bump) where `cargo run` may still recompile.
timeout: 300_000,
reuseExistingServer: !process.env.CI,
},
});