Reputation: 9915
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.
Upvotes: 4
Views: 689
Reputation: 1408
You can chain your promises
I use like this
Return this.app.client.click('.minimize').browserWindow.isVisible().should.be.equal(true)
Upvotes: 0
Reputation: 622
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.
Upvotes: 5