Cypress で RSpec の travel_to がしたいとき

結論

clock を使う。

docs.cypress.io

具体例

describe('My First Test', () => {
  it('Foo', () => {
    const travelToDateTime = new Date(
      new Date('2022-06-24 21:00:00').toLocaleString('ja-JP')
    ).getTime()

    cy.clock(travelToDateTime)

    cy.visit('/')
  })
})
Powered by はてなブログ