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).
I managed to fix this issue adding
TZ=UTC
to my.env
file. I'm using Mac though.