In the system I am working on we have some tests for leave balances which are timezone dependent. I noticed these would fail on CI before 10am local time, and pass for the rest of our (work) day.
Since our local timezone is UTC+10 I realised that our CI system was using UTC and therefore wasn’t accurate in its estimations.
I discovered there are two ways to ensure a consistent timezone in our CI system.
Firstly we set the timezoneId
for Playwright to our timezone using the list of timezones is available here.
This is our Playwright config file (playwright.config.ts
):
use: {
headless: true,
locale: 'en-AU',
timezoneId: 'Australia/Brisbane',
}
And secondly we make sure the timezone is set correctly on the CI docker images. We use Bitbucket Pipelines are the config file (bitbucket-pipelines.yml
) line looks like:
script:
- cp -f /usr/share/zoneinfo/Australia/Brisbane /etc/localtime # set timezone
- npm ci
- npm test
Setting both the system and browser ensures consistent timezone execution on CI and we’re eliminated our inconsistencies by implementing this.