-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathplaywright.config.ts
94 lines (89 loc) · 2.05 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";
import assert from "node:assert";
import { fileURLToPath } from "node:url";
import { existsSync, writeFileSync } from "node:fs";
dotenv.config({ path: ".env.test.local" });
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;
PLAYWRIGHT_PRISMIC_EMAIL: string;
PLAYWRIGHT_PRISMIC_PASSWORD: string;
}
}
}
assert.ok(
process.env.PLAYWRIGHT_PRISMIC_EMAIL,
"Missing PLAYWRIGHT_PRISMIC_EMAIL env variable.",
);
assert.ok(
process.env.PLAYWRIGHT_PRISMIC_PASSWORD,
"Missing PLAYWRIGHT_PRISMIC_PASSWORD env variable.",
);