I'm using Mocha and Chai as part of the web-component-tester tool to write my tests. As part of those tests, I need to wait for a part of the UI to update before doing an assertion.
The only way I've been able to figure out how to do this successfully is by using a timeout:
test("should update image", function(done) {
setTimeout(function() {
assert.equal(document.querySelector(".tp-revslider-mainul .tp-revslider-slidesli:nth-child(1) .tp-bgimg").getAttribute("src"), "https://someurl/image.jpg");
done();
}, 5000);
});
Is there a better way? CasperJS has a waitFor function that is great in situations like these, but I'm not sure how to do the same in Mocha.
Thx.
Aucun commentaire:
Enregistrer un commentaire