Skip to content

[💡 Feature]: Support configuring NODE_OPTIONS for ChromeDriver separately from NODE_OPTIONS for WDIO itself #12753

@tanin47

Description

@tanin47

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Idea 💡A new feature ideahelp wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions