jeudi 11 juin 2020

Cypress good practices with cy.wait

I have test, writed in Cypress, as frontend I use VueJS with SSR. It's SPA and I testing click through the menu.

before(() => {
   // mock data etc.
});

it('should check if component render properly without ssr', () => {
    cy.visit('url');
    cy.wait(1000);
    cy.get('.menuElement').click();
    cy.get('.something').should($something => {
        expect($something).to.have.length(10);
    });
});

In "good practices" created by Cypress, I shouldn't use cy.wait in this form. But is problem with that, becouse without this wait test is fail. I tried use:

  • { timeout: 10000 } as param in cy.get and cy.visit
  • aded something like .should('be.visible'); (for waiting when will be visable)
  • added route with cy.wait("@abc")

None of the above works.

Please suggest me a solution what should I do that everything works correctly in my case.

Aucun commentaire:

Enregistrer un commentaire