Skip to content

Commit 199fd05

Browse files
committed
feat: enhance Cypress browser launch options for CI
1 parent dae2b88 commit 199fd05

2 files changed

Lines changed: 30 additions & 16 deletions

File tree

.github/workflows/frontend-cicd.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,15 @@ jobs:
7979
install: false # Dependencies are already installed in a previous step
8080
start: npm start # Command to start the frontend application
8181
wait-on: ${{ env.CYPRESS_BASE_URL }} # Wait for the frontend to be available
82-
browser: chrome
83-
# Suppress WebGL warnings in headless CI environment
82+
# Note: browser parameter is ignored when command is used
8483
command: npm run test:e2e -- --env apiUrl=${{ env.REACT_APP_API_URL }}
8584
env:
8685
CI: true # Indicate that tests are running in a CI environment
8786
CYPRESS_BASE_URL: 'http://localhost:3000' # Base URL for the frontend application
8887
REACT_APP_API_URL: 'http://localhost:3001' # API URL for the backend
8988
GENERATE_SOURCEMAP: false # Suppress source map warnings during build
90-
# Chrome flags for headless mode to suppress WebGL warnings
91-
ELECTRON_EXTRA_LAUNCH_ARGS: '--disable-gpu --enable-unsafe-swiftshader'
89+
# Electron flags for headless CI mode to suppress WebGL/GPU warnings
90+
ELECTRON_EXTRA_LAUNCH_ARGS: '--disable-gpu --enable-unsafe-swiftshader --disable-software-rasterizer --disable-gpu-compositing --use-gl=swiftshader --ignore-gpu-blocklist'
9291

9392
# Step 8: Upload Cypress screenshots if tests fail
9493
- name: Upload Cypress Screenshots

cypress.config.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,36 @@ module.exports = defineConfig({
9696

9797
// Configure browser launch options
9898
on('before:browser:launch', (browser = {}, launchOptions) => {
99-
if (browser.family === 'chromium' || browser.name === 'chrome' || browser.name === 'electron') {
100-
// Fix for "Automatic fallback to software WebGL has been deprecated" in CI
101-
// These flags suppress WebGL warnings in headless/CI environments
102-
launchOptions.args.push('--enable-unsafe-swiftshader');
103-
launchOptions.args.push('--disable-gpu');
104-
launchOptions.args.push('--disable-software-rasterizer');
105-
launchOptions.args.push('--disable-dev-shm-usage');
106-
107-
// Only log in CI to avoid noise in local development
99+
// For Chrome and Chromium-based browsers (not Electron)
100+
if (browser.family === 'chromium' && browser.name !== 'electron') {
101+
// Fix for WebGL and GPU warnings in CI headless environments
102+
const gpuFlags = [
103+
'--enable-unsafe-swiftshader',
104+
'--disable-gpu',
105+
'--disable-software-rasterizer',
106+
'--disable-dev-shm-usage',
107+
'--disable-gpu-compositing',
108+
'--disable-gpu-rasterization',
109+
'--disable-gpu-sandbox',
110+
'--use-gl=swiftshader'
111+
];
112+
gpuFlags.forEach(flag => launchOptions.args.push(flag));
113+
114+
if (process.env.CI) {
115+
console.log(`Injecting Chrome flags for ${browser.name}:`, gpuFlags);
116+
}
117+
}
118+
119+
// For Electron browser - use environment variable approach
120+
// Electron doesn't support args the same way, the flags are passed via ELECTRON_EXTRA_LAUNCH_ARGS env var
121+
if (browser.name === 'electron') {
122+
// Electron handles GPU flags through environment variables set in CI
123+
// See ELECTRON_EXTRA_LAUNCH_ARGS in the workflow file
108124
if (process.env.CI) {
109-
console.log(`Injecting Chrome flags for ${browser.name}:`, launchOptions.args.filter(arg =>
110-
arg.includes('gpu') || arg.includes('swiftshader') || arg.includes('rasterizer')
111-
));
125+
console.log(`Running Electron in CI - GPU flags handled via ELECTRON_EXTRA_LAUNCH_ARGS env var`);
112126
}
113127
}
128+
114129
return launchOptions;
115130
});
116131

0 commit comments

Comments
 (0)