I'm trying to test my electron app with spectron and mocha;my application will close the first window after user login,so i need add some "wait action" to wait the second window to appear. But it seems setTimeout's callback works abnormal.
Asked
Active
Viewed 70 times
1 Answers
0
I think the settimeout function works asynchronous, so the promise chain will continue after you started the settimeout. So somehow you have to await the settimeout - have you tried wrapping it in a promise, and then return the promise?
return new Promise((resolve, reject) => {
setTimeout(async () => {
await this.app.client.windowByIndex(0); //I'm not even sure you need to await this
resolve();
}, 3000);
});

Garmien
- 185
- 1
- 9