-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
71 lines (67 loc) · 3.04 KB
/
Copy pathplaywright.config.ts
File metadata and controls
71 lines (67 loc) · 3.04 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
import { defineConfig, devices } from "@playwright/test";
/**
* End-to-end tests.
*
* The suite deliberately runs with **no secrets at all**. That isn't a shortcut — it's the
* only way it can be useful here. GitHub Actions does not expose repository secrets to pull
* requests from forks, and this project is built almost entirely on fork contributions. A
* suite that needed a real Supabase URL would go green for the maintainer and red for every
* outside contributor, which is worse than having no suite at all.
*
* So `e2e/mock-supabase.mjs` stands in for the database. supabase-js is just an HTTP client
* against PostgREST, so pointing `NEXT_PUBLIC_SUPABASE_URL` at a local fixture server gives
* the server components deterministic data — no secrets, no network, and no GitHub, which is
* also what the issue asks for ("do not test real GitHub OAuth in CI; mock the
* authentication state").
*
* `NEXT_PUBLIC_*` values are inlined by Next at build time, not read at runtime, which is why
* the app is built here with the mock's URL already set rather than having it injected later.
*/
export default defineConfig({
testDir: "./e2e",
// Fail the build rather than quietly skip, if someone leaves a `test.only` behind.
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
// One worker on CI: the suite shares a single app server and a single fixture server, so
// parallel workers would be racing over the same state for no real gain at this size.
workers: process.env.CI ? 1 : undefined,
reporter: process.env.CI ? [["github"], ["html", { open: "never" }]] : "list",
use: {
baseURL: "http://127.0.0.1:3000",
trace: "on-first-retry",
screenshot: "only-on-failure",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
webServer: [
{
command: "node e2e/mock-supabase.mjs",
url: "http://127.0.0.1:54321/health",
reuseExistingServer: !process.env.CI,
stdout: "pipe",
},
{
command: process.env.CI ? "npm run start" : "npm run build && npm run start",
url: "http://127.0.0.1:3000",
// A cold Next build is slow; the default 60s is not enough on a CI runner.
timeout: 240_000,
reuseExistingServer: !process.env.CI,
// Server-side runtime environment variables for the Next.js application in CI.
// NOTE: This is the single source of truth for runtime environment variables passed to the
// Next.js server when Playwright launches `npm run start` in CI. If you add a new server-side
// environment variable read at request time, configure it here so the server receives it.
env: {
NEXT_PUBLIC_SUPABASE_URL: "http://127.0.0.1:54321",
// Not real credentials, and not secret — the fixture server ignores them entirely.
// They exist only because the client refuses to construct without a key.
NEXT_PUBLIC_SUPABASE_ANON_KEY: "e2e-anon-key",
SUPABASE_SERVICE_ROLE_KEY: "e2e-service-role-key",
NEXT_TELEMETRY_DISABLED: "1",
},
},
],
});