Last week, I’ve been working at adding a distributed countdown to my Online Planning Poker App. As our team works from Paris and Beirut, I wanted to unit test that it would work well through different timezones. I found a surprisingly simple solution.
What Google told me
I first searched Google to see how to do it. I found 2 answers that looked promising :
- You can use moment-timezone to mock timezones in Jasmine which I unfortunately did not manage to use
- How to mock the browser’s timezone? which seemed a bit of hack
Known results for such a simple situation were disappointing !
What I ended up with
1 2 3
Obviously, the drawback is that it implies setting both the timezone and the time. This should be ok in most of unit tests though, but might be an issue in some cases.