1

I am doing snapshot tests with Jest and during one of those tests i am creating a new Date using new Date() the problem is when i run the tests locally on my computer the date is in german: Mon Jan 20 2020 01:00:00 GMT+0100 (Mitteleuropäische Normalzeit) and when i run the same test with my gitlab pipeline the text is in english Mon Jan 20 2020 00:00:00 GMT+0000 (Coordinated Universal Time). This results in my pipeline failing. Is there an option for globally setting my language for jest. I was able to set the timezone using process.env.TZ = 'UTC'; is there something similar for the language?

timmmmmb
  • 479
  • 3
  • 17
  • Can you update all the tests to use UTC dates for consistency across all environments? If so, check: [get UTC date (not UTC string) in javascript](https://stackoverflow.com/questions/57810435/get-utc-date-not-utc-string-in-javascript) – Metro Smurf Oct 27 '21 at 12:09
  • does this help? https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone But I would consider refactor the test itself to make it not depend on timezone. – spiritwalker Oct 27 '21 at 12:09
  • Can you use this answer: [reactjs - How do I set a timezone in my Jest config? - Stack Overflow](https://stackoverflow.com/questions/56261381/how-do-i-set-a-timezone-in-my-jest-config) – chrwahl Oct 27 '21 at 12:27
  • Does this answer your question? [get UTC date (not UTC string) in javascript](https://stackoverflow.com/questions/57810435/get-utc-date-not-utc-string-in-javascript) – Michael Freidgeim Jan 09 '22 at 03:10

0 Answers0