Cypress how can I check if the background changes in a div

Viewed 2108

I have a div in which I load dynamic image depending if the user clicks on a button.

<div style="background-image: url('myimage.png')"></div>

so far this is my test:

cy.get('label').first().click();

cy.get('.bg-cover').should('have.css', 'background-image');

But how can I check if the background src changes.

1 Answers

I'm not sure you already resolved this, but I leave my solution for other

cy.get('.bg-cover')
  .should('have.css', 'background-image')
  .and('include', 'myimage.png')
Related