-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
81 lines (79 loc) · 3.56 KB
/
Copy pathplaywright.config.ts
File metadata and controls
81 lines (79 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// End-to-end suite — see e2e/README.md for how it's laid out and what the
// fixtures give you. `dotenv/config` runs first because the DB helpers in
// e2e/db.ts import src/lib/prisma, which needs DATABASE_URL at import time.
import "dotenv/config";
import { defineConfig, devices } from "@playwright/test";
export const BASE_URL = "http://localhost:3000";
export const ADMIN_STORAGE_STATE = "e2e/.auth/admin.json";
export default defineConfig({
testDir: "./e2e",
// Files run in parallel across workers; tests inside one file stay in order.
// Everything that touches the DB creates its own uniquely-named rows, so
// cross-file interference is limited to the per-IP comment rate limit — see
// the note in e2e/README.md before writing a test that posts via the form.
fullyParallel: false,
// Two, not three. Three workers overload the *dev server*, not the machine:
// measured symptoms were a public page 500ing with next-auth's
// "useSession must be wrapped in a <SessionProvider />" during SSR, and
// server actions arriving with truncated bodies ("Unexpected end of JSON
// input" on /posts/[id]/edit), neither reproducible in isolation and neither
// an app defect. Failure rate was roughly 1 full run in 3.5 at three
// workers, 0 in 8 at two — for the same ~50s wall clock, because the dev
// server is the bottleneck rather than the parallelism.
workers: process.env.CI ? 1 : 2,
forbidOnly: !!process.env.CI,
// No local retries on purpose: a retry that turns a red run green hides
// exactly the collab/WS timing regressions this suite exists to catch.
retries: process.env.CI ? 2 : 0,
// Generous because `next dev` compiles a route on first request, and
// /posts/[id]/edit pulls in TipTap + Yjs.
timeout: 60_000,
expect: { timeout: 10_000 },
reporter: process.env.CI ? [["github"], ["html", { open: "never" }]] : [["list"], ["html", { open: "never" }]],
use: {
baseURL: BASE_URL,
trace: "retain-on-failure",
screenshot: "only-on-failure",
video: "off",
},
projects: [
{ name: "setup", testMatch: /auth\.setup\.ts/, teardown: "cleanup" },
{ name: "cleanup", testMatch: /cleanup\.teardown\.ts/ },
{
name: "chromium",
use: { ...devices["Desktop Chrome"], storageState: ADMIN_STORAGE_STATE },
dependencies: ["setup"],
testIgnore: /dark-mode\.spec\.ts/,
},
// Scoped to one spec via testMatch, not the whole suite — duplicating
// every test under a second color scheme would roughly double wall clock
// for near-zero incremental coverage, since nothing else in the suite
// asserts on color (STYLE.md's Dark theme section).
{
name: "chromium-dark",
testMatch: /dark-mode\.spec\.ts/,
use: { ...devices["Desktop Chrome"], storageState: ADMIN_STORAGE_STATE, colorScheme: "dark" },
dependencies: ["setup"],
},
],
// `reuseExistingServer` is unconditional rather than `!process.env.CI`: the
// user frequently has `npm run dev:all` up already, and CLAUDE.md is explicit
// that a dev server we didn't start is not ours to kill. If nothing is
// listening, Playwright starts both halves itself and stops them at the end.
webServer: [
{
command: "npm run dev",
url: BASE_URL,
reuseExistingServer: true,
timeout: 180_000,
},
{
// A raw WebSocket server, so wait on the TCP port — an HTTP probe of the
// Hocuspocus endpoint proves nothing useful.
command: "npm run collab",
port: Number(process.env.COLLAB_PORT ?? 1234),
reuseExistingServer: true,
timeout: 60_000,
},
],
});