We use Cypress and cypress-image-snapshot
for snapshot testing. Unfortunately we have issues with our colleagues based in another countries running the tests since they fail because of different timezones.
In our date related components we pass strings in ISO 8601 format to set the date.
For our jest tests we use mocks (Components using Date objects produce different snapshots in different timezones) but not quite sure how to handle the situation in Cypress.
We use Cypress and cypress-image-snapshot
for snapshot testing. Unfortunately we have issues with our colleagues based in another countries running the tests since they fail because of different timezones.
In our date related components we pass strings in ISO 8601 format to set the date.
For our jest tests we use mocks (Components using Date objects produce different snapshots in different timezones) but not quite sure how to handle the situation in Cypress.
Share Improve this question edited Nov 10, 2019 at 17:01 jonrsharpe 122k30 gold badges266 silver badges473 bronze badges asked Nov 10, 2019 at 16:45 pollxpollx 6999 silver badges23 bronze badges 3 |1 Answer
Reset to default 18You can open browser with different TZ from server by adding specific timezone before open, in this way
"scripts": {
"cypress:open": "TZ=America/New_York cypress open",
"cypress:run": "TZ=America/New_York cypress run"
}
cy.clock
, have you looked into that? – jonrsharpe Commented Nov 10, 2019 at 16:47cy.clock()
is for speeding up JS timer functions likesetTimeout()
, nothing to do with timezones so you can ignore that approach. – Ackroydd Commented Nov 13, 2019 at 19:37