-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
89 lines (83 loc) · 1.97 KB
/
playwright.config.ts
File metadata and controls
89 lines (83 loc) · 1.97 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
import assert from "node:assert"
import { existsSync, writeFileSync } from "node:fs"
import { fileURLToPath } from "node:url"
import { defineConfig, devices } from "@playwright/test"
try {
process.loadEnvFile(".env.test.local")
} catch {}
export const STORAGE_STATE = fileURLToPath(
new URL("./tests/infra/.storage-state.json", import.meta.url),
)
if (!existsSync(STORAGE_STATE)) writeFileSync(STORAGE_STATE, JSON.stringify({}))
// https://playwright.dev/docs/test-configuration
export default defineConfig({
testDir: "./tests",
testMatch: "**/*.spec.*",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: "html",
use: {
trace: "on-first-retry",
},
projects: [
{
name: "setup",
testMatch: "setup.ts",
teardown: "teardown",
use: {
storageState: STORAGE_STATE,
},
},
{
name: "app-router",
dependencies: ["setup"],
use: {
...devices["Desktop Chrome"],
baseURL: "http://localhost:4321",
storageState: STORAGE_STATE,
},
},
{
name: "pages-router",
dependencies: ["setup", "app-router"],
use: {
...devices["Desktop Chrome"],
baseURL: "http://localhost:4322",
storageState: STORAGE_STATE,
},
},
{
name: "teardown",
testMatch: "teardown.ts",
use: {
storageState: STORAGE_STATE,
},
},
],
webServer: [
{
command: "npm run --workspace app-router dev",
port: 4321,
reuseExistingServer: !process.env.CI,
},
{
command: "npm run --workspace pages-router dev",
port: 4322,
reuseExistingServer: !process.env.CI,
},
],
})
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeJS {
interface ProcessEnv {
CI: boolean
E2E_PRISMIC_EMAIL: string
E2E_PRISMIC_PASSWORD: string
}
}
}
assert.ok(process.env.E2E_PRISMIC_EMAIL, "Missing E2E_PRISMIC_EMAIL env variable.")
assert.ok(process.env.E2E_PRISMIC_PASSWORD, "Missing E2E_PRISMIC_PASSWORD env variable.")