-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathplaywright.config.ts
74 lines (63 loc) · 2.06 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
import path, { dirname } from "node:path"
import { fileURLToPath } from "node:url"
// Import required Node.js utilities
import { defineConfig, devices } from "@playwright/test"
// Server configuration
const PORT = process.env.PORT || 3000
const baseURL = `http://localhost:${PORT}`
// ES modules dirname setup
// Required because ES modules don't have __dirname global
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
/**
* Playwright Configuration
* Configures end-to-end testing environment and test projects
*/
export default defineConfig({
// Global test timeout (30 seconds)
timeout: 30 * 1000,
// Directory containing test files
testDir: path.join(__dirname, "e2e"),
// Retry failed tests in CI
retries: process.env.CI ? 2 : 0,
// Directory for test artifacts (screenshots, videos, etc.)
outputDir: "test-results/",
// Development server configuration
webServer: {
command: "bun run ci", // Command to start the server
url: baseURL, // Server URL to wait for
timeout: 120 * 1000, // Server startup timeout (2 minutes)
reuseExistingServer: !process.env.CI, // Reuse server in development
},
// Global test configuration
use: {
baseURL, // Base URL for navigation
trace: "retry-with-trace", // Capture traces on retry
},
// Test projects with different configurations
projects: [
// Global setup project
{
name: "Setup",
testMatch: /global\.setup\.ts/, // Setup file pattern
},
// Tests requiring authentication
{
name: "Authenticated State Tests",
testMatch: /.*authenticated.spec.ts/, // Auth test pattern
use: {
...devices["Desktop Chrome"], // Use Chrome
storageState: "playwright/.clerk/user.json", // Auth state file
},
dependencies: ["Setup"], // Run setup first
},
// Tests for unauthenticated state
{
name: "Unauthorized State Tests",
testMatch: /.*unauthorized.spec.ts/, // Unauth test pattern
use: {
...devices["Desktop Chrome"], // Use Chrome
},
},
],
})