-
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
113 lines (109 loc) · 3.58 KB
/
playwright.config.ts
File metadata and controls
113 lines (109 loc) · 3.58 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
import { defineConfig, devices } from "@playwright/test";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
/**
* See https://playwright.dev/docs/test-configuration
*/
const skipWebServer = process.env.PLAYWRIGHT_SKIP_WEBSERVER === "true";
const collectCoverage = process.env.COVERAGE === "true";
const shardIndex = process.env.SHARD_INDEX || "1";
// Configure reporters based on coverage mode
const reporters: any[] = [["list"]];
if (collectCoverage) {
const coverageDir = path.resolve(__dirname, `./coverage/e2e/shard-${shardIndex}`);
reporters.push([
"monocart-reporter",
{
name: `E2E Coverage Report (Shard ${shardIndex})`,
outputFile: path.join(coverageDir, "report.html"),
coverage: {
entryFilter: (entry: { url: string }) => {
// Only collect coverage for our source files
return entry.url.includes("/dist/") && entry.url.endsWith(".js");
},
sourceFilter: (sourcePath: string) => {
// Include only src files, exclude node_modules
return sourcePath.includes("/src/") && !sourcePath.includes("node_modules");
},
reports: [["lcovonly", { file: path.join(coverageDir, "lcov.info") }], ["v8"]]
}
}
]);
}
export default defineConfig({
testDir: "./test/integration",
/* Maximum time one test can run for */
/* Firefox needs more time for nested iframes and JavaScript execution */
timeout: 60 * 1000,
/* 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,
/* Maximize parallel workers - defaults to 50% of CPU cores, this uses all cores */
workers: process.env.CI ? "50%" : "100%",
/* Reporter to use */
reporter: reporters,
/* Shared settings for all the projects below */
use: {
/* Base URL to use in actions like `await page.goto('/')` */
baseURL: "http://localhost:3000",
/* Collect trace when retrying the failed test */
trace: "on-first-retry",
/* Record video: "off" | "on" | "on-first-retry" | "retain-on-failure" */
/* "on" records all tests, "retain-on-failure" records all but only keeps failed ones */
video: process.env.RECORD_VIDEO === "true" ? "on" : "on-first-retry",
/* Take a screenshot for failed tests */
screenshot: {
mode: "only-on-failure",
fullPage: true
}
},
/* Configure projects for major browsers */
projects: process.env.CI
? [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] }
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] }
},
{
name: "player-wrapper-demos",
testMatch: "test/integration/demos/player-wrapper.spec.ts"
}
]
: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] }
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] }
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] }
},
{
name: "player-wrapper-demos",
testMatch: "test/integration/demos/player-wrapper.spec.ts"
}
],
/* Run local server before starting the tests */
webServer: skipWebServer
? undefined
: {
command: "npm run test:integration:server",
url: "http://localhost:3000",
reuseExistingServer: true,
stdout: "pipe",
stderr: "pipe",
timeout: 120000 // Increase timeout to 2 minutes
}
});