Spectron test sequential actions
electron, javascript, spectron, testing
Solution
You need to `return` the results of your callback functions.
it('should minimize the application', () => {
return this.app.client.click('.minimize').then(() => {
return this.app.client.browserWindow.isVisible().then((isVisible) => {
return expect(isVisible).to.be.equal(true);
});
});
});
Alternatively, drop the wrapping curly braces, and the arrow function will return the result automatically.
it('should minimize the application', () =>
this.app.client.click('.minimize').then(() =>
this.app.client.browserWindow.isVisible().then((isVisible) =>
expect(isVisible).to.be.equal(true);
);
);
);
I don't think that's quite as readable, but that might just be me.
Problem
I am testing electron application with spectron. I have found in documentation examples on how to get number of windows and it is quite trivial. But what I am looking is how to check the state of one element after I have click on another element. Here I am trying to check if application is visible after I have minimized it. But this test always pass, for true and for false. ``` it('should minimize the application', () => { return this.app.client.click('.minimize').then(() => { this.app.client.browserWindow.isVisible().then((isVisible) => { expect(isVisible).to.be.equal(true); }); }); }) ``` I am using mocha with chai asserts. Please advise on how can I check if application ( or particular element is visible ) after I have clicked on another element.