【问题标题】:How to set to other time zone in Cypress while running test?运行测试时如何设置赛普拉斯的其他时区?
【发布时间】:2021-01-26 05:04:36
【问题描述】:
cy.clock()
cy.visit('http://localhost:3333')
cy.get('#search').type('Acme Company')
cy.tick(1000)
// more test code here

// restore the clock
cy.clock().then((clock) => {
  clock.restore()
})

运行测试时如何在赛普拉斯设置时区? 我在越南,我的时区是 GMT+7 当我运行测试时,我希望我的测试在时区 GMT+8 中运行。

【问题讨论】:

    标签: timezone cypress


    【解决方案1】:

    要设置现在的时间戳,您可以使用:

    const now = new Date(Date.UTC(2021, 1, 26)).getTime();
    cy.clock(now);
    

    文档中的更多信息:cy.clock() - Now

    【讨论】:

      猜你喜欢
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-27
      • 2019-12-27
      • 2019-07-29
      • 2020-03-06
      • 1970-01-01
      相关资源
      最近更新 更多