-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
119 lines (104 loc) · 3.49 KB
/
playwright.config.ts
File metadata and controls
119 lines (104 loc) · 3.49 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
import { defineConfig, devices } from "@playwright/test";
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
require("dotenv").config({ path: ".env.local" });
/**
* Required environment variables for E2E tests
* In CI: These are set via GitHub Actions secrets
* Locally: These are loaded from .env.local via dotenv
*/
const REQUIRED_ENV_VARS = [
"NEXT_PUBLIC_SUPABASE_URL",
"NEXT_PUBLIC_SUPABASE_ANON_KEY",
"NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY",
"CLERK_SECRET_KEY",
] as const;
const OPTIONAL_ENV_VARS = ["FOOTBALL_DATA_API_KEY"] as const;
/**
* Validate that required environment variables are set in CI
* Locally, .env.local handles this, so we only validate in CI
*/
function validateEnvironmentVariables() {
if (!process.env.CI) {
// Skip validation locally - .env.local should handle this
return;
}
const missing = REQUIRED_ENV_VARS.filter((varName) => !process.env[varName]);
if (missing.length > 0) {
throw new Error(
`Missing required environment variables in CI: ${missing.join(", ")}\n` +
"Please ensure these are set in GitHub Actions secrets.",
);
}
}
// Validate before running tests
validateEnvironmentVariables();
/**
* Build environment object for webServer
* Pass through all environment variables needed by Next.js
*/
function buildWebServerEnv(): Record<string, string> {
const env: Record<string, string> = {
NEXT_PUBLIC_FEATURE_ADMIN_PUSH_NOTIFICATIONS: "true",
};
// Add all required and optional env vars
[...REQUIRED_ENV_VARS, ...OPTIONAL_ENV_VARS].forEach((varName) => {
env[varName] = process.env[varName] || "";
});
return env;
}
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
globalSetup: require.resolve("./playwright/global.setup"),
testDir: "./e2e",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in tests for like `await page.goto('/ ')`. */
baseURL: process.env.PLAYWRIGHT_BASE_URL || "http://localhost:3000",
launchOptions: {
env: {
NEXT_PUBLIC_FEATURE_CLASIFICACION: "true",
NEXT_PUBLIC_FEATURE_RSVP: "true",
NEXT_PUBLIC_FEATURE_PARTIDOS: "true",
NEXT_PUBLIC_FEATURE_NOSOTROS: "true",
NEXT_PUBLIC_FEATURE_UNETE: "true",
NEXT_PUBLIC_FEATURE_CLERK_AUTH: "true",
// Feature flags for E2E testing
},
},
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},
/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
storageState: "playwright/.clerk/user.json",
},
},
],
/* Run your local dev server before starting the tests */
webServer: {
command: "NEXT_PUBLIC_FEATURE_ADMIN_PUSH_NOTIFICATIONS=true npm run dev",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000, // Increased timeout to 120 seconds
env: buildWebServerEnv(),
},
});