Accessing Electron APIs
If you wish to access the Electron APIs then you will need to import (or require) the preload and main scripts in your app.
Somewhere near the top of your preload script, load wdio-electron-service/preload
conditionally, e.g.:
preload/index.ts
if (process.env.TEST === 'true') {
import('wdio-electron-service/preload');
}
And somewhere near the top of your main index file (app entry point), load wdio-electron-service/main
conditionally, e.g.:
main/index.ts
if (process.env.TEST === 'true') {
import('wdio-electron-service/main');
}
For security reasons it is encouraged to ensure electron main process access is only available when the app is being tested.
This is the reason for the above dynamic imports wrapped in conditionals. You will need to specify the TEST environment variable at the top of your WDIO config file:
wdio.conf.ts
// ...
process.env.TEST = 'true';
// ...