Writing my first cypress test in conjunction with percy visual tester. I load my landing page, check a few links and then take a percy snapshot. The issue is that the background image hasn't loaded in the snapshot.
I can get it to appear by artifically waiting before taking the snapshot, but I'd prefer to have a cypress assertion to check this instead.
Here is the css:
.bg-hero {
@include image("/images/background/landing.jpg", center);
}
Here is the html:
<div class="bg-hero bg top-header bg-header-top" id="#"></div>
I tried: cy.get('.bg-hero').should('be.visible');
Am currently using: cy.wait(3000);
thanks
You can use Route command as this
cy.route('imageURL').as('image')
cy.wait('@image')
cy.get('.bg-hero').should('be.visible');
The issue was with Percy and not Cypress. I had to tweak a setting such that Percy would wait a while longer. Percy command line docs reference a network idle timeout setting. Thanks to Rob@Percy for putting me onto this. It has made my visual testing much more robust.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With