-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
70 lines (68 loc) · 2.32 KB
/
playwright.config.ts
File metadata and controls
70 lines (68 loc) · 2.32 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
import { defineConfig, devices } from "@playwright/test";
// Check if we should use production build for tests
const useProdBuild = process.env.E2E_USE_PROD_BUILD === "true" || process.env.CI;
const requestedWorkers = Number(process.env.E2E_WORKERS || (process.env.CI ? "4" : "2"));
const e2eWorkers =
Number.isFinite(requestedWorkers) && requestedWorkers > 0 ? Math.floor(requestedWorkers) : 1;
export default defineConfig({
globalTeardown: "./apps/web/e2e/global-teardown.ts",
testDir: "./apps/web/e2e",
// Keep intra-file ordering for stateful suites while parallelizing by worker across files.
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 1,
workers: e2eWorkers,
reporter: [
["html", { open: "never" }],
["list"],
["./apps/web/e2e/helpers/test-run-reporter.js"],
],
use: {
baseURL: "http://localhost:3000",
trace: "on-first-retry",
screenshot: "only-on-failure",
},
projects: [
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
},
testIgnore: [/auth\.spec\.ts/, /public-pages\.spec\.ts/],
},
{
// No-auth suites validate explicit unauthenticated/public boundaries.
name: "chromium-no-auth",
use: {
...devices["Desktop Chrome"],
storageState: undefined,
},
testMatch: [/auth\.spec\.ts/, /public-pages\.spec\.ts/],
},
],
webServer: useProdBuild
? {
// Production build: build first, then start
command:
"bash scripts/build-widget-for-tests.sh && pnpm build:web && NEXT_PUBLIC_WIDGET_URL=/opencom-widget.iife.js pnpm --filter @opencom/web start",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
timeout: 300 * 1000, // 5 minutes for build + start
env: {
NEXT_PUBLIC_WIDGET_URL: "/opencom-widget.iife.js",
ALLOW_TEST_DATA: "true",
},
}
: {
// Development server (default)
command:
"bash scripts/build-widget-for-tests.sh && NEXT_PUBLIC_WIDGET_URL=/opencom-widget.iife.js pnpm dev:web",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
timeout: 180 * 1000,
env: {
NEXT_PUBLIC_WIDGET_URL: "/opencom-widget.iife.js",
ALLOW_TEST_DATA: "true",
},
},
});