-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I migrated the test running off mocha (#368 ) along with esm (see #363 and #365 ). But in the end I realized testing electron still requires more, because:
node:testwhether via cli orrunruns tests in a node sub-processes- Electron api access requires an (sub) process
The current setup tried to make ^ work, by:
- Starting an electron main process
- Creating a hidden browser window, and loading test bundles as a preload script
- Having node:test test and describe commands in the preload (test) script
This emits the expected output, but there is no way to trigger process.exit(1) off failures or listen to events, without dipping into internals, AFAIK. There are a few solutions I can think of:
- Have each
node:teststart its own electron sub-process and execute the scenario(s) - Run proper QA style tests (Selenium, etc)
- Isolate and mock electron apis and run the preload tests as regular node backend tests
1 and 2 are spelled out in the electron docs. 3 is the approach I think we should take instead, because the preload bundles only use two electron apis really: electron-store and opening dialogs; mocking them should be easy. Then the tests can run like regular node backend tests. This is mostly possible because the application architecture, at the time of this writing, with only a few exceptions is:
- Main browser bundle - operates like typical browser code
- Preload bundle - operates like typical backend code
They talk to each other via a client exposed on window via useClient.