-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
174 lines (168 loc) · 5.56 KB
/
playwright.config.ts
File metadata and controls
174 lines (168 loc) · 5.56 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import { defineConfig } from "@playwright/test";
/**
* Each project maps to a single webServer. When PLAYWRIGHT_PROJECT is set
* (e.g. in CI matrix jobs), only that project and its server are configured,
* so each CI runner only starts the one server it needs.
*/
const projectServers = {
"pages-router": {
testDir: "./tests/e2e/pages-router",
use: { baseURL: "http://localhost:4173" },
server: {
command: "npx vp run vinext#build && npx vp dev --port 4173",
cwd: "./tests/fixtures/pages-basic",
port: 4173,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"app-router": {
testDir: "./tests/e2e",
testMatch: ["**/app-router/**/*.spec.ts", "**/og-image.spec.ts"],
use: { baseURL: "http://localhost:4174" },
server: {
command: "npx vp dev --port 4174",
cwd: "./tests/fixtures/app-basic",
port: 4174,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"cloudflare-pages-router": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-pages-router/**/*.spec.ts",
"**/pages-router/instrumentation-startup.spec.ts",
],
use: { baseURL: "http://localhost:4177" },
server: {
command: "npx vp build && npx wrangler dev --port 4177",
cwd: "./examples/pages-router-cloudflare",
port: 4177,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"pages-router-prod": {
testDir: "./tests/e2e/pages-router-prod",
server: {
// Use node to invoke the CLI directly — npx vinext may not be on PATH
// in fixture subdirectories since vinext is a workspace dependency.
command:
"npx tsc -p ../../../packages/vinext/tsconfig.json && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4175",
cwd: "./tests/fixtures/pages-basic",
port: 4175,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-workers": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-workers/**/*.spec.ts",
"**/app-router/instrumentation.spec.ts",
"**/og-image.spec.ts",
],
use: { baseURL: "http://localhost:4176" },
server: {
// Build app-router-cloudflare with Vite, then serve with wrangler dev (miniflare)
command: "npx vp build && npx wrangler dev --config dist/server/wrangler.json --port 4176",
cwd: "./examples/app-router-cloudflare",
port: 4176,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-dev": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-dev/**/*.spec.ts",
"**/app-router/instrumentation.spec.ts",
"**/og-image.spec.ts",
],
use: { baseURL: "http://localhost:4178" },
server: {
// Run vite dev (not wrangler) against the cloudflare example so that
// configureServer() is exercised with @cloudflare/vite-plugin loaded.
command: "npx vp dev --port 4178",
cwd: "./examples/app-router-cloudflare",
port: 4178,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"cloudflare-pages-router-dev": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-pages-router-dev/**/*.spec.ts",
"**/pages-router/instrumentation-startup.spec.ts",
],
use: { baseURL: "http://localhost:4179" },
server: {
command: "npx vp dev --port 4179",
cwd: "./examples/pages-router-cloudflare",
port: 4179,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"static-export": {
testDir: "./tests/e2e/static-export",
use: { baseURL: "http://localhost:4180" },
server: {
// Build the static export fixture, then serve the output with a
// lightweight static file server. No vinext runtime is needed —
// the output is pure pre-rendered HTML files.
command:
"npx tsc -p ../../../packages/vinext/tsconfig.json && node ../../../packages/vinext/dist/cli.js build && node ../../../tests/e2e/static-export/serve-static.mjs dist/client 4180",
cwd: "./tests/fixtures/static-export",
port: 4180,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"app-with-src": {
testDir: "./tests/e2e/app-with-src",
use: { baseURL: "http://localhost:4181" },
server: {
command: "npx vp dev --port 4181",
cwd: "./tests/fixtures/app-with-src",
port: 4181,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
};
type ProjectName = keyof typeof projectServers;
const selected = process.env.PLAYWRIGHT_PROJECT;
if (selected && !(selected in projectServers)) {
throw new Error(
`Unknown PLAYWRIGHT_PROJECT: "${selected}". ` +
`Valid: ${Object.keys(projectServers).join(", ")}`,
);
}
const activeProjects: ProjectName[] = selected
? [selected as ProjectName]
: (Object.keys(projectServers) as ProjectName[]);
export default defineConfig({
testDir: "./tests/e2e",
timeout: 30_000,
retries: 1,
// GitHub reporter adds inline failure annotations in PR diffs.
reporter: process.env.CI ? [["list"], ["github"]] : [["list"]],
use: {
headless: true,
// Use chromium only — fast and sufficient for our tests
browserName: "chromium",
},
projects: activeProjects.map((name) => {
const p = projectServers[name];
return {
name,
testDir: p.testDir,
...("testMatch" in p ? { testMatch: p.testMatch } : {}),
...("use" in p ? { use: p.use } : {}),
};
}),
webServer: activeProjects.map((name) => projectServers[name].server),
});