Skip to content

Commit 849f2f7

Browse files
committed
E2E: Make sure Cypress doesn't disable GPU on Linux
1 parent 7e0ab60 commit 849f2f7

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

cypress/support/launchBrowser.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@
66
// this will produce higher resolution images and videos
77
// https://on.cypress.io/browser-launch-api
88

9+
const disableGPULaunchOption = '--disable-gpu';
10+
11+
/**
12+
* Cypress might want to disable HW acceleration, but we need that for WebGL
13+
* support which is mandatory for the Map to work in Jore. Remove the disabling
14+
* launch option arg.
15+
*
16+
* @param launchOptions
17+
*/
18+
function dontDisableGPU(
19+
launchOptions: Cypress.BeforeBrowserLaunchOptions,
20+
): Cypress.BeforeBrowserLaunchOptions {
21+
if (launchOptions.args.includes(disableGPULaunchOption)) {
22+
console.log(
23+
"Cypress has disabled GPU acceleration in the browser's launch optiopns. But we need GPU for the map. Re-enable and hope fot the best 🤞",
24+
);
25+
26+
return {
27+
...launchOptions,
28+
args: launchOptions.args.filter((arg) => arg !== disableGPULaunchOption),
29+
};
30+
}
31+
32+
return launchOptions;
33+
}
34+
935
/**
1036
* The browser width and height we want to get our screenshots and videos
1137
* will be of that resolution. + Normal launch options
@@ -128,7 +154,8 @@ export function onLaunchBrowser(
128154
browser: Cypress.Browser,
129155
launchOptions: Cypress.BeforeBrowserLaunchOptions,
130156
): Cypress.BeforeBrowserLaunchOptions {
131-
const withScreenSize = applyScreenSizeOptions(browser, launchOptions);
157+
const withGPUAcceleration = dontDisableGPU(launchOptions);
158+
const withScreenSize = applyScreenSizeOptions(browser, withGPUAcceleration);
132159
const withReducedMotion = applyReducedMotionOptions(browser, withScreenSize);
133160

134161
return withReducedMotion;

0 commit comments

Comments
 (0)