spectron
spectron copied to clipboard
The app.stop() do not fail when the electron app canceled the quit with a beforeunload
If the electron app has a beforeunload that cancel the app quit like this
// index.html
window.onbeforeunload = function(e) {
console.log('app quit canceled')
return false
};
Then try to close the spectron app
// test.js
if (this.app && this.app.isRunning()) {
return this.app.stop().then(function() {
console.log('stopped')
})
}
The output is "stopped" even if app is still running. The expected behaviour is the this.app.stop() promise rejects
Electron 1.1.1 Spectron 3.1.1
I'm running into this as well. Now I'm very very new to Spectron, but it's unexpected behavior.
after(function (done) {
done();
console.log("Fin")
return app.stop();
});
I have the same problem. Resolved it by doing return app.client.url('about:blank').then(() => app.stop());
thanks for @mbaer3000 .your solution works for me now Iām looking for a headless solution that would not see a client
I am still having this. My tests are passing and the window stays open. I tried the workaround this did not do the trick.
afterEach(() => {
if (app && app.isRunning()) {
return app.client.url('about:blank').then(() => app.stop());
}
});