Configuration
This document covers all configuration options for the WDIO Electron Service, including service options and Chromedriver configuration.
Service Configuration
The service can be configured by setting wdio:electronServiceOptions either on the service level or capability level, in which capability level configurations take precedence, e.g. the following WebdriverIO configuration:
wdio.conf.ts
export const config = {
// ...
services: [
[
'electron',
{
appBinaryPath: '/foo/bar/myApp'
},
],
],
capabilities: [
{
'browserName': 'electron',
'wdio:electronServiceOptions': {
appBinaryPath: '/foo/bar/myOtherApp'
appArgs: ['foo', 'bar'],
},
},
],
// ...
};
...would result in the following configuration object:
{
"appBinaryPath": "/foo/bar/myOtherApp",
"appArgs": ["foo", "bar"]
}
Service Options
The service supports the following configuration options:
appArgs:
An array of string arguments to be passed through to the app on execution of the test run. Electron command line switches and some Chromium switches can be used here.
Type: string[]
appBinaryPath:
The path to the Electron binary of the app for testing. In most cases the service will determine the path to your app automatically (check here), but if this fails for some reason, e.g. your app is in a different repository from your tests, then it is recommended to set this value manually.
If you manually set the path to the Electron binary, the path will be in different formats depending on the build tool you are using, how that tool is configured, and which OS you are building the app on.
Here are some examples of binary paths using default build configurations for a hypothetical app called myApp which is built in the workspace/myApp directory:
MacOS (Arm)
'/workspace/myApp/dist-electron/mac-arm64/myApp.app/Contents/MacOS/myApp'; // Electron Builder
'/workspace/myApp/out/myApp-darwin-arm64/myApp.app/Contents/MacOS/myApp'; // Electron Forge
MacOS (Intel)
'/workspace/myApp/dist-electron/mac-x64/myApp.app/Contents/MacOS/myApp'; // Electron Builder
'/workspace/myApp/out/myApp-darwin-x64/myApp.app/Contents/MacOS/myApp'; // Electron Forge
MacOS (Universal)
'/workspace/myApp/dist-electron/mac-universal/myApp.app/Contents/MacOS/myApp'; // Electron Builder
'/workspace/myApp/out/myApp-darwin-universal/myApp.app/Contents/MacOS/myApp'; // Electron Forge
Linux
'/workspace/myApp/dist-electron/linux-unpacked/myApp'; // Electron Builder
'/workspace/myApp/out/myApp-linux-x64/myApp'; // Electron Forge
Windows
'C:\\workspace\\myApp\\dist-electron\\win-unpacked\\myApp.exe'; // Electron Builder
'C:\\workspace\\myApp\\out\\myApp-win32-x64\\myApp.exe'; // Electron Forge
Note:
- The above examples assume electron-builder's
"directories": { "output": "dist-electron" }config (default is"dist"). Your actual binary path depends on your electron-builder configuration. - Electron Forge uses a standardised output directory which can be represented as
out/{appName}-{OS}-{arch}
Type: string
appEntryPoint:
The path to the unpackaged entry point of the app for testing, e.g. your main.js. You will need Electron installed to use this feature. The appEntryPoint value overrides appBinaryPath if both are set.
Warning - Deeplink Testing:
appEntryPoint cannot be used for protocol handler testing on Windows or Linux. Protocol handlers on these platforms require an OS-registered executable binary to function correctly with the browser.electron.triggerDeeplink() method. You must use a packaged binary instead (either by setting appBinaryPath or letting the service auto-detect it). macOS works with both packaged binaries and script-based apps.
See the Deeplink Testing guide for complete setup instructions.
Type: string