Reputation: 499
Have assertion with 401 request, which passes, but want, also, to confirm popup error which appears (that part fails). Below are screenshots of page layout and test results:
And code which wrote:
it('should not be loaded any data without mocks', () => {
cy.visit('/partURL');
cy.server();
cy.route({
method: 'GET',
url: '**/forms?workspace?**',
}).as('myUrlAlias');
cy.wait('@myUrlAlias')
.its('status')
.should('eq', 401);
cy.get('div.inner_page__content div.embedded_alert__wrapper img')
.should('have.attr', 'src')
.and('include', 'alt');
});
Upvotes: 1
Views: 430
Reputation: 1427
It seems to me your chain on the target element is wrong. .and()
checks for assertion on the original element, if you wana check the attr - you should chain a second .should(). Here an alternative idea:
it('should not be loaded any data without mocks', () => {
cy.visit('/partURL');
cy.server();
cy.route({
method: 'GET',
url: '**/forms?workspace?**',
}).as('myUrlAlias');
cy.wait('@myUrlAlias')
.its('status')
.should('eq', 401);
cy.get('img[alt="Warning icon"]')
.should('exist')
});
Upvotes: 1