Vangi
Vangi

Reputation: 1

How to get changed time using cypress?

In the test ,I have to change a comment and save In the edit history I can see who changed what and the time when it is changed. I want to verify the time it was changed.

Two things to verify

  1. Get the current time when I change the comment.
  2. Get the time from the edit history and it should match to the time in the step 1.

Your help is appreciated

Upvotes: 0

Views: 461

Answers (1)

Fody
Fody

Reputation: 31904

There is the cy.clock() command,

Essentially, cy.clock() freezes the time in the app so you don't get any variation due to fast/slow processing.

Adapted from the example in the docs:

const now = new Date(2021, 3, 14) // month is 0-indexed

cy.clock(now)        // use a specific date for testing purposes

// change the comment

cy.get('#comment').should('have.value', '04/14/2021')

Upvotes: 1

Related Questions