首页 > 解决方案 > 运行测试时如何设置赛普拉斯的其他时区?

问题描述

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 运行。

标签: timezonecypress

解决方案


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

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

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


推荐阅读