So here is the problem. I am migrating from moment to dayjs. There is a lot of code covered with tests, where dayjs is used. Some of them I would like to make run on specific time zone.
With moment I was using moment-timezone library.
in some test data.test.ts
import moment from 'moment-timezone'; moment.tz.setDefault('Europe/Berlin');
It would affect both moment and moment.tz and moment() will show Berlin time.
With the same approach, when we use
dayjs.tz.setDefault('Europe/Berlin')
only dayjs.tz() is affected and changed to Berlin time zone, but dayjs() instance still keeps running on local time. I don't want to change the code to write with dayjs.tz(), I want to keep dayjs() logic and make tests run in timezone I specify.
Has anyone faced the same problem or knows how to solve it? I searched everywhere, but could not find a satisfying answer.
I can set process.env.TZ='SOME ZONE', but I don't want to affect the whole node enviroment.
Any clue will be much appriciated.