forked from Cap-go/capgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
115 lines (109 loc) · 3.68 KB
/
playwright.config.ts
File metadata and controls
115 lines (109 loc) · 3.68 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
109
110
111
112
113
114
115
import type { PlaywrightTestConfig } from '@playwright/test'
import { env } from 'node:process'
import { defineConfig, devices } from '@playwright/test'
import {
getPlaywrightStripeApiBaseUrl,
getStripeEmulatorPort,
} from './scripts/playwright-stripe'
import { getSupabaseWorktreeConfig } from './scripts/supabase-worktree-config'
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// Keep local and CI Playwright runs headless so they do not steal window focus.
const headless = true
const isCi = !!env.CI
const reuseExistingServer = !isCi
const webServerTimeout = isCi ? 360_000 : 300_000
// The local Supabase edge runtime becomes unstable under parallel Chromium workers.
// Keep Playwright serial by default and allow an explicit override for debugging.
const configuredWorkers = Number(env.PLAYWRIGHT_WORKERS || '1')
const webServer: PlaywrightTestConfig['webServer'] = []
const { ports: supabasePorts } = getSupabaseWorktreeConfig()
const localSupabaseUrl = `http://127.0.0.1:${supabasePorts.api}`
const localApiDomain = `127.0.0.1:${supabasePorts.api}/functions/v1`
const localSupabaseAnonKey
= env.SUPABASE_ANON_KEY || 'sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH'
const localStripeEmulatorPort = getStripeEmulatorPort(env)
const localStripeApiBaseUrl = getPlaywrightStripeApiBaseUrl(env)
if (!env.SKIP_STRIPE_EMULATOR_START) {
webServer.push({
command: `STRIPE_EMULATOR_PORT=${localStripeEmulatorPort} bun run stripe:emulator`,
port: localStripeEmulatorPort,
timeout: 60_000,
reuseExistingServer,
stdout: 'pipe',
})
}
else {
console.log('Skipping Stripe emulator server')
}
if (!env.SKIP_BACKEND_START) {
webServer.push({
command: `ENV=local STRIPE_SECRET_KEY=sk_test_emulator STRIPE_API_BASE_URL=${localStripeApiBaseUrl} STRIPE_WEBHOOK_SECRET=testsecret WEBAPP_URL=http://localhost:5173 bun run backend:playwright`,
url: `${localSupabaseUrl}/functions/v1/ok`,
timeout: webServerTimeout,
reuseExistingServer,
})
}
else {
console.log('Skipping backend server')
}
if (env.SKIP_FRONTEND_START) {
console.log('Skipping frontend server')
}
else {
webServer.push({
command: `ENV=local SUPA_URL=${localSupabaseUrl} SUPA_ANON=${localSupabaseAnonKey} API_DOMAIN=${localApiDomain} CAPTCHA_KEY='' bun run serve:local`,
port: 5173,
timeout: webServerTimeout,
reuseExistingServer,
stdout: 'pipe',
})
}
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/e2e',
/* Keep browser runs serial to avoid edge runtime CPU cancellations. */
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!env.CI,
/* Never retry, the entire thing is stateful and retries will never succeed because of the modifications to supabase in the previous attempt */
retries: 0,
workers: configuredWorkers,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
['list', { printSteps: true }],
['github'],
['html', { outputFolder: './playwright-report/', open: 'never' }],
],
use: {
headless,
trace: 'on',
video: 'on',
screenshot: 'on',
baseURL: 'http://localhost:5173/',
viewport: { width: 1280, height: 720 },
actionTimeout: 30_000,
navigationTimeout: 30_000,
// storageState: 'playwright/.auth/user1.json',
},
expect: {
/* CI/CD is VERY slow, I am sorry */
timeout: 40_000,
},
webServer,
// globalSetup: './tests/global-auth-setup',
timeout: 180 * 1000,
projects: [
{
name: 'chromium',
use: {
// storageState: 'playwright/.auth/user1.json',
...devices['Desktop Chrome'],
},
},
],
})