mercredi 18 décembre 2019

Check multiple current time using Moment.js in Cypress

I'm going to check the time interval between request and response that prints graph. I need to get millisecond interval. I used Moment.js included in Cypress, but it did not work.

it("time interval check", () => {
    cy.get("div.v-text-field__slot > input")
      .eq(0)
      .type("Vue.js, React.js, Angular.js {enter}", { delay: 0 });
    const num1 = Cypress.moment().valueOf();
    cy.log(num1);
    cy.get("canvas#trendChart").should("be.visible");
    const num2 = Cypress.moment().valueOf();
    cy.log(num2);
    cy.wrap(Cypress.moment().subtract(num1).valueOf())
      .should('to.be.lessThan', 1000);
  });

I know this solution is really stupid, but I hope you understand that it is because I use this tool for the first time.

Time interval check with cy.log

It showed too short time interval. (XHR Duration was 403ms)

How can I solve this problem?

Aucun commentaire:

Enregistrer un commentaire