Skip to content

Show example how to restore synthetic clock #429

Open
@bahmutov

Description

@bahmutov
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')
})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions