cypress-example-kitchensink icon indicating copy to clipboard operation
cypress-example-kitchensink copied to clipboard

Show example how to restore synthetic clock

Open bahmutov opened this issue 5 years ago • 1 comments

it('restores', () => {
  cy.clock(+ new Date())
  cy.visit('http://localhost:3000/sudoku')
  // make sure the application has rendered
  // and the synthetic clock started working
  cy.get('.game__cell--filled').should('have.length', 45)

  cy.tick(600 * 1000) // 10 minutes
  cy.contains('.status__time', '10:00')

  // resume the clock
  cy.tick().then(clock => {
    clock.restore()
  })
  // the clock is restored to original value
  // thus the timer will start measuring again
  // from the original date passed to "cy.clock"
  cy.contains('.status__time', '00:03')
})

bahmutov avatar Jun 23 '20 12:06 bahmutov

People have trouble finding this info https://twitter.com/huchenme/status/1275225026531225600

bahmutov avatar Jun 23 '20 12:06 bahmutov