Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
84 lines (81 loc) · 3.43 KB
/
Copy pathplaywright.config.ts
File metadata and controls
84 lines (81 loc) · 3.43 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
82
83
84
import { defineConfig, devices } from '@playwright/test'
/**
* End-to-end tests against a production build (`next build` first), served in
* test mode: a fresh local libSQL database (scripts/e2e-db.mjs), magic links
* written to .e2e/magic-links instead of emailed, and TMDB answered from
* e2e/fixtures/tmdb. No secrets are needed.
*/
const PORT = Number(process.env.E2E_PORT || 3105)
const baseURL = `http://localhost:${PORT}`
export default defineConfig({
testDir: './e2e',
fullyParallel: false,
workers: 1,
retries: process.env.CI ? 1 : 0,
timeout: 60_000,
expect: { timeout: 10_000 },
reporter: process.env.CI ? [['github'], ['html', { open: 'never' }]] : 'list',
use: {
baseURL,
// The first-visit welcome pop-up (lib/welcome.ts) is marked seen so it
// does not cover the pages under test, and analytics is declined
// (lib/consent.ts) so no spec loads Google Analytics; e2e/consent.spec.ts
// starts from a clean state instead.
storageState: {
cookies: [
{
name: 'n8-consent',
value: 'denied',
domain: 'localhost',
path: '/',
expires: -1,
httpOnly: false,
secure: false,
sameSite: 'Lax',
},
],
origins: [
{
origin: baseURL,
localStorage: [{ name: 'nettrailers-welcome-seen-v1', value: 'e2e' }],
},
],
},
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
// A fixed time zone outside the ones asked about analytics consent, so
// the consent banner (lib/consent.ts) never shows unless a spec asks.
timezoneId: 'America/Los_Angeles',
},
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
webServer: {
command: `node scripts/e2e-db.mjs && npx next start -p ${PORT}`,
url: baseURL,
timeout: 120_000,
reuseExistingServer: false,
stdout: 'pipe',
env: {
APP_ENV: 'test',
TURSO_DATABASE_URL: 'file:.e2e/test.db',
AUTH_SECRET: 'e2e-only-auth-secret-not-used-anywhere-else',
AUTH_URL: baseURL,
NEXT_PUBLIC_APP_URL: baseURL,
E2E_MAGIC_LINK_DIR: '.e2e/magic-links',
// The admin account for e2e/admin.spec.ts.
ADMIN_EMAILS: 'admin@nettrailers.test',
// Lets e2e/admin.spec.ts call the service-only stats route the way the Worker does.
CRON_SECRET: 'e2e-only-cron-secret',
// Cloudflare's always-pass Turnstile test secret, matching the test
// site key the build falls back to (hooks/useTurnstile.ts).
TURNSTILE_SECRET_KEY: '1x0000000000000000000000000000000AA',
// Placeholder: TMDB answers from fixtures (unless E2E_TMDB_RECORD=1).
TMDB_API_KEY: process.env.TMDB_API_KEY || 'fixture',
E2E_TMDB_RECORD: process.env.E2E_TMDB_RECORD || '',
NEXT_PUBLIC_SENTRY_DSN: '',
// NEXT_PUBLIC_GA_MEASUREMENT_ID is inlined at build time, so it is
// set on the build, not here: CI builds with the made-up
// G-E2ETEST000 (.github/workflows/ci.yml) so e2e/consent.spec.ts
// can test the consent banner and the GA loader.
},
},
})