|
6 | 6 | // this will produce higher resolution images and videos |
7 | 7 | // https://on.cypress.io/browser-launch-api |
8 | 8 |
|
| 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 | + |
9 | 35 | /** |
10 | 36 | * The browser width and height we want to get our screenshots and videos |
11 | 37 | * will be of that resolution. + Normal launch options |
@@ -128,7 +154,8 @@ export function onLaunchBrowser( |
128 | 154 | browser: Cypress.Browser, |
129 | 155 | launchOptions: Cypress.BeforeBrowserLaunchOptions, |
130 | 156 | ): Cypress.BeforeBrowserLaunchOptions { |
131 | | - const withScreenSize = applyScreenSizeOptions(browser, launchOptions); |
| 157 | + const withGPUAcceleration = dontDisableGPU(launchOptions); |
| 158 | + const withScreenSize = applyScreenSizeOptions(browser, withGPUAcceleration); |
132 | 159 | const withReducedMotion = applyReducedMotionOptions(browser, withScreenSize); |
133 | 160 |
|
134 | 161 | return withReducedMotion; |
|
0 commit comments