Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle timezones in Cypress snapshot tests?

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.

like image 408
pollx Avatar asked Nov 10 '19 16:11

pollx


1 Answers

You 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"
}
like image 113
Juan Pablo Cáceres Avatar answered Nov 09 '22 17:11

Juan Pablo Cáceres