I'm using spectron to run integration tests against my electron app. Everything is working fine apart from attempting to test that app settings are persisted properly between app restarts.
While running tests, my app starts up with new temporary userData
directory for every test which ensures that the tests are isolated. This means the the persistence testing needs to ideally occur in a single test and to achieve this I have to restart the app in the middle of the test. There's an app.restart
method so this has got to be supported right?
I'm using the following spectron test code:
// save some settings here
await app.restart();
await app.client.waitUntilWindowLoaded()
// do some more checking to ensure the app is fully loaded
// check the settings here
However I'm getting the following error:
Error: waitUntilWindowLoaded Promise was rejected with the following reason:
Error: A session id is required for this command but wasn't found in the response payload
What's the correct way to do this? I've also tried stopping the Application instance and starting a new one with similar results.
userData
is the electron path where the whole Chromium user app storage is saved. I'm using the electronapp.setPath('userData', x)
API to set this. Everything is stored there indexedDb, GPU cache, etc. I'm setting it topath.join(os.tmpdir(), 'spectron', randomString)
. – Allegeapp.setLoginItemSettings([options])
to draw out your settings in each test in a beforeEach? Or maybe this issue has some relevance. – Carbonization