Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
108 lines (103 loc) · 3.67 KB
/
Copy pathplaywright.config.ts
File metadata and controls
108 lines (103 loc) · 3.67 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { defineConfig } from '@playwright/test'
import type { PlaywrightTestConfig } from '@playwright/test'
import fs from 'node:fs'
import path from 'node:path'
function loadEnvFile(envPath: string) {
let contents: string
try {
contents = fs.readFileSync(envPath, 'utf8')
} catch (error) {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false
throw error
}
const lines = contents.split('\n')
for (const line of lines) {
const trimmed = line.trim()
if (!trimmed || trimmed.startsWith('#')) continue
const eqIndex = trimmed.indexOf('=')
if (eqIndex === -1) continue
const key = trimmed.slice(0, eqIndex).trim()
let value = trimmed.slice(eqIndex + 1).trim()
if (
(value.startsWith('"') && value.endsWith('"')) ||
(value.startsWith("'") && value.endsWith("'"))
) {
value = value.slice(1, -1)
}
if (!(key in process.env)) process.env[key] = value
}
return true
}
function loadRootEnv() {
const repoRoot = path.resolve(__dirname, '..')
if (loadEnvFile(path.join(repoRoot, '.env'))) return
const gitCommonDir = path.resolve(repoRoot, '.git')
let gitFile: string
try {
gitFile = fs.readFileSync(gitCommonDir, 'utf8').trim()
} catch (error) {
if (
(error as NodeJS.ErrnoException).code === 'ENOENT' ||
(error as NodeJS.ErrnoException).code === 'EISDIR'
)
return
throw error
}
const match = gitFile.match(/^gitdir:\s*(.+)$/)
if (!match) return
const worktreeGitDir = path.resolve(repoRoot, match[1])
const commonDirPath = path.join(worktreeGitDir, 'commondir')
const commonDir = fs.readFileSync(commonDirPath, 'utf8').trim()
const mainGitDir = path.resolve(worktreeGitDir, commonDir)
loadEnvFile(path.join(mainGitDir, '..', '.env'))
}
loadRootEnv()
const gfsAuthCrossBrowserProjects: NonNullable<PlaywrightTestConfig['projects']> =
process.env.E2E_GFS_AUTH_CROSS_BROWSER === '1'
? [
{
name: 'chrome-gfs-auth',
testMatch: /gfs-operator-journey\.spec\.ts/,
grep: /authenticated operator reaches Global File System/,
use: { channel: 'chrome' },
},
{
name: 'firefox-gfs-auth',
testMatch: /gfs-operator-journey\.spec\.ts/,
grep: /authenticated operator reaches Global File System/,
use: { browserName: 'firefox' },
},
]
: []
// Reporter is fixed to `list` at config level (instead of defaulting to the
// `line` reporter that buffers output) so that background runs — and the
// wrapper scripts in scripts/e2e/run-e2e-*.sh — always emit a line-per-test
// progress stream. A previous run of the registry suite in the background
// produced a silent stall because `line` reporter rewrites the last line;
// keeping `list` here makes the contract consistent across minikube and
// the example-dev GKE wrappers. Override with `--reporter=<name>` on the CLI
// when you need html/json for CI artifacts.
export default defineConfig({
testDir: './e2e',
testIgnore: '**/support/**',
timeout: 300_000, // 5 min default — long-running workflow specs override via test.setTimeout()
expect: { timeout: 120_000 },
reporter: [['list']],
use: {
baseURL:
process.env.CONTROL_UI_BASE_URL || process.env.CONTROL_UI_URL || 'http://localhost:3000',
headless: true,
screenshot: 'only-on-failure',
trace: 'on-first-retry',
},
retries: 0,
projects: [
{ name: 'chromium', testIgnore: '**/gfs-upload-v2.spec.ts', use: { browserName: 'chromium' } },
{
name: 'large-upload',
testMatch: /gfs-upload-v2\.spec\.ts/,
use: { browserName: 'chromium', trace: 'retain-on-failure' },
},
...gfsAuthCrossBrowserProjects,
],
})