-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Is your feature request related to a problem?
Here's the background: webdriverio-community/wdio-electron-service#331
tldr: we were stuck in getting Electron (dev mode, not prod) to start within WDIO. We've figured that the root cause is because NODE_OPTIONS was set on ChromeDriver. The NODE_OPTIONS (intended for WDIO) happens to cause issue in Electron.
Specifically, WDIO sets NODE_OPTIONS=' --loader ts-node/esm/transpile-only --no-warnings' (ref), which is carried over to ChromeDriver and, thus, Electron.
To verify the impact of this env, we can run: NODE_OPTIONS=' --loader ts-node/esm/transpile-only --no-warnings' ./node_modules/.bin/electron in Terminal, and Electron will crash.
Describe the solution you'd like.
We want to be able to to configure NODE_OPTIONS for ChromeDriver separately from the NODE_OPTIONS for WDIO.
Today NODE_OPTIONS for WDIO is carried over to ChromeDriver; in turn, it is carried over to Electron (dev mode), and Electron crashes because of it.
Here's the line that we want to inject NODE_OPTIONS only for ChromeDriver: https://github.com/webdriverio/webdriverio/blob/main/packages/wdio-utils/src/node/startWebDriver.ts#L86
We want to change it to something like:
driverProcess = cp.spawn(chromedriverExcecuteablePath, driverParams, { env: {...process.env, NODE_OPTIONS: configured_node_options } })
I would also consider adding shell: true, so it closely resembles when the Electron is started directly from command line.
Describe alternatives you've considered.
We could just filter out NODE_OPTIONS altogether as well like:
driverProcess = cp.spawn(chromedriverExcecuteablePath, driverParams, { env: { ...process.env, NODE_OPTIONS: null } })
This also might be preferable because it's more minimal, and we currently don't have a reason to set NODE_OPTIONS for ChromeDriver/Electron.
Additional context
We are trying to get wdio-electron-service to support testing against Electron (dev mode), not just prod mode.
Electron (prod mode) doesn't have the same problem because the prod mode forbids NODE_OPTIONS (ref).
cc @goosewobbler @christian-bromann
Code of Conduct
- I agree to follow this project's Code of Conduct