mardi 21 avril 2020

Cypress 4.4.0 - How to use cy.clock(), cy.tick() in simple login in order to work

using v 4.4.0 Cypress E2E testing framework. Trying a simple test just to log in into the webshop as customer, and to check, if he is logged off after 1 hour. Cookies are also set for 1h in webshop.

The user is still not logged off.

I have managed to make simple script:

 context('Secure logging off', () => {
  beforeEach(() => {
    cy.loginAsGrownupCustomer()
    cy.fixture('products').as('products')
  })

  it('after inactivity', function () {
    const { simpleProduct } = this.products
    const waitSeconds = 4000;
    const waitMilliseconds = waitSeconds * 1000;
    const buffer = 1000;
    cy.clock();
    cy.visit('/');
    cy.tick(waitMilliseconds + buffer);
    cy.get('[data-qa="logout warning"]').should('be.visible');
  });
})

Tried also to extend time const waitSeconds = 4000; for thousands of seconds but still no luck, user is still in logged in status.

Aucun commentaire:

Enregistrer un commentaire