2

I have normal Jest snapshot tests for a component that calls toDateString() and toTimeString().

The tests all pass when I run locally because both the tests and my component run in my current time zone (EST); however, when I check the tests into GitLab, the snapshot runs in EST, but the component calls the methods in Coordinated Universal Time, causing it to fail.

Is there a way to mock timezones in Jest? Or is there any other solution?

I am on Windows (not my choice).

skyboyer
  • 22,209
  • 7
  • 57
  • 64
telemo
  • 21
  • 2

1 Answers1

1

I managed to fix this issue adding TZ=UTC to my .env file. I'm using Mac though.

lucas
  • 1,105
  • 8
  • 14