I'm migrating my tests from Intern.js to Nightwatch.js and I'm sure it's not the recommended way of writing tests, but my tests asynchronously make browser command calls (my tests use a class that has its own command queue). The Nightwatch command queue can be empty sometimes depending on what's executing, but will eventually be populated. I need a way to manually tell Nightwatch when it's done, and just wait until then, otherwise the browser will close too early.
I can do something like this:
finished() {
let done = false;
//will run at the end of my class's internal command queue
this.command
.then(() => {
done = true;
});
//will cause nightwatch to wait until my command queue is done
this.browser.perform(doneFn => {
const check = () => {
if (done) {
return doneFn();
}
setTimeout(check, 10);
}
check();
});
}But in that case perform() will time out after waiting 10 seconds, and I don't seem to be able to configure that. I could otherwise run a sequence of ~9 second perform() calls but it just sounds too hacky. I could rewrite to depend on nightwatch command queue instead, but that'd also be a lot more work to rewrite everything.
Aucun commentaire:
Enregistrer un commentaire