fix(webdriverio): allow gpu in headless chrome (#10376) · vitest-dev/vitest@f310abe (original) (raw)

File tree

Original file line number Diff line number Diff line change
@@ -190,9 +190,18 @@ export class WebdriverBrowserProvider implements BrowserProvider {
190 190 const options = this.project.config.browser
191 191 const browser = this.browserName
192 192 if (browser !== 'safari' && options.headless) {
193 -const [key, args] = headlessMap[browser]
193 +const [key, defaultArgs] = headlessMap[browser]
194 194 const currentValues = (this.options?.capabilities as any)?.[key] |
195 -const newArgs = [...(currentValues.args |
195 +const currentArgs: string[] = currentValues.args |
196 +
197 +const hasEnableGpu = browser === 'chrome' && (currentArgs.includes('--enable-gpu') |
198 +
199 +const argsToAdd = hasEnableGpu
200 + ? defaultArgs.filter(arg => arg !== 'disable-gpu')
201 + : defaultArgs
202 +
203 +const newArgs = [...currentArgs, ...argsToAdd]
204 +
196 205 capabilities[key] = { ...currentValues, args: newArgs as any }
197 206 }
198 207