-
-
Notifications
You must be signed in to change notification settings - Fork 173
/
playwright.config.ts
76 lines (67 loc) · 1.84 KB
/
playwright.config.ts
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
import { defineConfig, type PlaywrightTestConfig } from "@playwright/test"
const CI = !!process.env.CI
type InferServer<T> = Exclude<T extends Array<infer U> ? U : T, undefined>
type WebServer = InferServer<PlaywrightTestConfig["webServer"]>
export function getWebServer(): WebServer {
const framework = process.env.FRAMEWORK || "react"
const frameworks: Record<string, WebServer> = {
react: {
cwd: "./examples/next-ts",
command: "cross-env PORT=3000 pnpm dev",
url: "http://localhost:3000",
reuseExistingServer: !CI,
},
vue: {
cwd: "./examples/vue-ts",
command: "pnpm vite --port 3001",
url: "http://localhost:3001",
reuseExistingServer: !CI,
},
solid: {
cwd: "./examples/solid-ts",
command: "pnpm vite --port 3002",
url: "http://localhost:3002",
reuseExistingServer: !CI,
},
svelte: {
cwd: "./examples/svelte-ts",
command: "pnpm vite --port 3003",
url: "http://localhost:3003",
reuseExistingServer: !CI,
},
}
return frameworks[framework]
}
const webServer = getWebServer()
export default defineConfig({
testDir: "./e2e",
outputDir: "./e2e/results",
testMatch: "*.e2e.ts",
fullyParallel: !CI,
timeout: 30_000,
expect: { timeout: 10_000 },
forbidOnly: !!CI,
reportSlowTests: null,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : "50%",
reporter: [
process.env.CI ? ["github", ["junit", { outputFile: "e2e/junit.xml" }]] : ["list"],
["html", { outputFolder: "e2e/report", open: "never" }],
],
webServer,
use: {
baseURL: webServer.url,
trace: "retain-on-failure",
screenshot: "only-on-failure",
video: "retain-on-failure",
locale: "en-US",
timezoneId: "GMT",
},
})
declare global {
namespace NodeJS {
interface ProcessEnv {
FRAMEWORK: string
}
}
}