Search code examples
javascriptimagehrefcypress

How can I use cypress to assert that an image is the correct one?


I'm trying to test a case where a user can insert a URL for their profile and want to make sure that the right image is loaded up. Is there a way where I can assert that the picture's src is the right one?


Solution

  • you are talking about this feature check it out cypress docs as an example

    cy.visit(URL);
    cy.get('your_selector').should('have.attr', 'src', '/your_picture_src')