ext-apps/playwright.config.ts
Olivier Chafik 1ea1e9ef43
test: exclude screenshot-gen from default E2E run; wire pdf-server tests (#537)
Bug 1: generate-grid-screenshots.spec.ts was running on every CI E2E
invocation because playwright.config.ts had no testIgnore. This spec
writes examples/*/grid-cell.png as a side effect — it's meant to be
invoked only via npm run generate:screenshots.

Added testIgnore gated on GENERATE_SCREENSHOTS env var (Playwright's
testIgnore is stronger than explicit CLI file args, so a plain ignore
would break generate:screenshots). Passed the env var through the
docker invocation in generate:screenshots.

  Before: npx playwright test --list → 82 tests in 3 files
  After:  npx playwright test --list → 65 tests in 2 files
  GENERATE_SCREENSHOTS=1 ... --list → 17 tests in 1 file (still works)

Bug 2: examples/pdf-server/server.test.ts (448 LOC, 34 tests) was
never run — root script was 'bun test src'. Changed to 'bun test src
examples'. Only one .test. file exists in examples/ so no noise.

  Before: npm test → 87 pass across 3 files
  After:  npm test → 121 pass across 4 files
2026-03-06 17:13:40 +00:00

58 lines
1.9 KiB
TypeScript

import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./tests/e2e",
// Exclude the screenshot generation spec from default runs.
// It writes examples/*/grid-cell.png as a side effect and is meant to be
// invoked only via `npm run generate:screenshots` (which sets
// GENERATE_SCREENSHOTS=1 to bypass this ignore).
testIgnore: process.env.GENERATE_SCREENSHOTS
? []
: ["**/generate-grid-screenshots.spec.ts"],
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 2 : 16, // Parallel execution now works with factory pattern
timeout: 30000, // 30s per test
reporter: process.env.CI ? "list" : "html",
// Use platform-agnostic snapshot names (no -darwin/-linux suffix)
snapshotPathTemplate:
"{testDir}/{testFileDir}/{testFileName}-snapshots/{arg}{ext}",
use: {
baseURL: "http://localhost:8080",
trace: "on-first-retry",
screenshot: "only-on-failure",
},
projects: [
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
// Use default Chromium everywhere for consistent screenshot rendering
// Run `npm run test:e2e:docker` locally for CI-identical results
},
},
],
// Run examples server before tests
// Supports EXAMPLE=<folder> env var to run a single example (e.g., EXAMPLE=say-server npm run test:e2e)
webServer: {
command: "npm run examples:start",
url: "http://localhost:8080",
// Always start fresh servers to avoid stale state issues
reuseExistingServer: false,
// 3 minutes to allow uv to download Python dependencies on first run
timeout: 180000,
// Pass through EXAMPLE env var to filter to a single server
env: {
...process.env,
EXAMPLE: process.env.EXAMPLE ?? "",
},
},
// Snapshot configuration
expect: {
toHaveScreenshot: {
maxDiffPixelRatio: 0.06,
animations: "disabled",
},
},
});