-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcypress.config.ts
More file actions
110 lines (108 loc) · 4.3 KB
/
cypress.config.ts
File metadata and controls
110 lines (108 loc) · 4.3 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
import { defineConfig } from "cypress";
// Centralize report directories with proper typing
const REPORTS_BASE_DIR = "cypress";
const REPORTS = {
junit: `${REPORTS_BASE_DIR}/junit`,
mochawesome: `${REPORTS_BASE_DIR}/mochawesome`,
videos: `${REPORTS_BASE_DIR}/videos`,
screenshots: `${REPORTS_BASE_DIR}/screenshots`,
artifacts: `${REPORTS_BASE_DIR}/artifacts`,
} as const;
export default defineConfig({
screenshotsFolder: REPORTS.screenshots,
videosFolder: REPORTS.videos,
experimentalMemoryManagement: true,
video: true,
screenshotOnRunFailure: true,
trashAssetsBeforeRuns: true,
viewportWidth: 1280,
viewportHeight: 800,
waitForAnimations: false,
pageLoadTimeout: 30000, // Increase timeout to 30 seconds
requestTimeout: 5000,
retries: {
runMode: 2,
openMode: 1,
},
// Simplified reporter configuration to avoid CommonJS conflicts
reporter: "spec",
e2e: {
baseUrl: "http://localhost:5173",
specPattern: "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",
supportFile: "cypress/support/e2e.ts",
testIsolation: true,
retries: {
runMode: 1,
openMode: 0,
},
defaultCommandTimeout: 8000,
chromeWebSecurity: false,
video: true,
videosFolder: "cypress/videos",
screenshotsFolder: "cypress/screenshots",
downloadsFolder: "cypress/downloads",
fixturesFolder: "cypress/fixtures",
responseTimeout: 10000,
setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Cypress.PluginConfigOptions {
// Add browser launch options to suppress WebGL warnings
on("before:browser:launch", (browser, launchOptions) => {
if (browser.family === "chromium" && browser.name !== "electron") {
// Add flags to suppress WebGL warnings and enable software rendering
launchOptions.args.push("--enable-unsafe-swiftshader");
launchOptions.args.push("--disable-features=VizDisplayCompositor");
launchOptions.args.push("--disable-gpu");
// Only disable sandbox in CI environments (required for containerized environments)
// Security trade-off: --no-sandbox disables Chrome's security sandbox, which is necessary
// for running Chrome in Docker/containerized CI but reduces security isolation.
// This is safe in ephemeral CI containers but should not be used in persistent environments.
if (process.env.CI) {
launchOptions.args.push("--no-sandbox");
}
launchOptions.args.push("--disable-dev-shm-usage");
// Suppress specific WebGL warnings
launchOptions.args.push("--disable-logging");
launchOptions.args.push("--silent");
launchOptions.args.push("--log-level=3");
}
return launchOptions;
});
return config;
},
},
component: {
devServer: {
framework: "react",
bundler: "vite",
},
specPattern: "src/**/*.cy.{js,jsx,ts,tsx}",
supportFile: "cypress/support/component.ts",
setupNodeEvents(on, _config) {
// implement node event listeners here
on("before:browser:launch", (browser, launchOptions) => {
if (browser.family === "chromium" && browser.name !== "electron") {
// Add flags to suppress WebGL warnings and enable software rendering
launchOptions.args.push("--enable-unsafe-swiftshader");
launchOptions.args.push("--disable-features=VizDisplayCompositor");
launchOptions.args.push("--disable-gpu");
// Only disable sandbox in CI environments (required for containerized environments)
// Security trade-off: --no-sandbox disables Chrome's security sandbox, which is necessary
// for running Chrome in Docker/containerized CI but reduces security isolation.
// This is safe in ephemeral CI containers but should not be used in persistent environments.
if (process.env.CI) {
launchOptions.args.push("--no-sandbox");
}
launchOptions.args.push("--disable-dev-shm-usage");
// Suppress specific WebGL warnings
launchOptions.args.push("--disable-logging");
launchOptions.args.push("--silent");
launchOptions.args.push("--log-level=3");
}
return launchOptions;
});
},
indexHtmlFile: "cypress/support/component-index.html",
},
});