forked from Remitwise-Org/Remitwise-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
94 lines (82 loc) · 3.35 KB
/
Copy pathplaywright.config.ts
File metadata and controls
94 lines (82 loc) · 3.35 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
85
86
87
88
89
90
91
92
93
94
import { defineConfig, devices } from '@playwright/test';
import path from 'path';
import { VR_VIEWPORTS } from './tests/e2e/shared-viewports';
// ---------------------------------------------------------------------------
// Visual-regression snapshot update flag.
// Set PLAYWRIGHT_UPDATE_SNAPSHOTS=1 in the environment to regenerate baselines.
// ---------------------------------------------------------------------------
const updateSnapshots = process.env.PLAYWRIGHT_UPDATE_SNAPSHOTS === '1' ? 'all' : 'none';
export default defineConfig({
testDir: './tests/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html'],
// Dot reporter is compact and works well in CI alongside html.
['dot'],
],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
extraHTTPHeaders: {
'x-playwright-test': 'true',
},
// @ts-expect-error reducedMotion is a valid Playwright context option
reducedMotion: 'reduce',
// Consistent colour scheme for snapshot stability.
colorScheme: 'dark',
},
// ---------------------------------------------------------------------------
// Snapshot configuration
// ---------------------------------------------------------------------------
updateSnapshots,
snapshotPathTemplate:
'{testDir}/__snapshots__/{testFilePath}/{projectName}/{arg}{ext}',
projects: [
// -----------------------------------------------------------------------
// Functional e2e suite — all spec files except visual-regression.
// -----------------------------------------------------------------------
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
testIgnore: ['**/visual-regression.spec.ts'],
},
// -----------------------------------------------------------------------
// Visual-regression projects — one per target viewport / browser combo.
// Each project maps to one CI matrix entry so snapshots are isolated and
// reproducible across runs.
// -----------------------------------------------------------------------
...VR_VIEWPORTS.map(({ label, width, height }) => ({
name: `vr-chromium-${label}`,
use: {
...devices['Desktop Chrome'],
viewport: { width, height },
},
testMatch: '**/visual-regression.spec.ts',
})),
],
webServer: {
command: 'npm run dev',
// Issue #1518 – probe the health endpoint for readiness: the root route
// currently 500s on main (pre-existing app bug), and readiness should
// mean "server is up", not "every page renders" — the specs test pages.
url: 'http://localhost:3000/api/health',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
// Ensure correct working directory in CI
cwd: path.resolve(__dirname),
// 🔥 Critical: Inject required environment variables for CI
env: {
DATABASE_URL: `file:${path.resolve(__dirname, 'prisma/ci.db')}`, // Required for Prisma in CI
SESSION_PASSWORD:
'supersecurelongsessionpasswordatleast32characters!!',
AUTH_SECRET: 'ci-test-secret',
// Optional but safe defaults for tests
NEXT_PUBLIC_APP_URL: 'http://localhost:3000',
STELLAR_NETWORK: 'testnet',
SOROBAN_RPC_URL: 'https://soroban-testnet.stellar.org',
},
},
});