-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathplaywright.config.js
87 lines (79 loc) · 2.09 KB
/
playwright.config.js
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
import path from "path";
import { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";
import { fileURLToPath } from "url";
// Replicate __dirname functionality in ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
dotenv.config({ path: path.resolve(__dirname, ".env.local") });
// Simplified environment variable handling
const requiredEnvVars = {
REACT_APP_USERNAME: process.env.REACT_APP_USERNAME,
REACT_APP_PASSWORD: process.env.REACT_APP_PASSWORD,
REACT_APP_URL: process.env.REACT_APP_URL,
};
// Validate required environment variables
Object.entries(requiredEnvVars).forEach(([key, value]) => {
if (!value) {
throw new Error(
`Required environment variable ${key} is missing. Please add it to .env.local`
);
}
});
/**
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: "./playwright/tests",
headless: true, // Run in headless mode for faster execution
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: "html",
globalSetup: "./playwright/global-setup.js",
use: {
baseURL: process.env.REACT_APP_URL || "http://localhost:3000",
storageState: "./playwright/.auth/state.json",
trace: "on-first-retry",
navigationTimeout: 30000,
actionTimeout: 15000,
},
projects: [
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
},
},
{
name: "firefox",
use: {
...devices["Desktop Firefox"],
},
},
{
name: "webkit",
use: {
...devices["Desktop Safari"],
},
},
{
name: "edge",
use: {
...devices["Desktop Edge"],
},
},
],
webServer: {
command: "yarn run test:e2e:start",
url: process.env.REACT_APP_URL || "http://localhost:3000",
reuseExistingServer: !process.env.CI,
timeout: 30000,
env: requiredEnvVars,
},
});