简体   繁体   中英

Setting timezone in Protractor e2e tests

I have some Protractor e2e tests in which I deal with timezone. On my local machine they pass, on Appveyor they don't.

I found out it's a timezone setting issue (different settings on Appveyor).

Is there a way to set the timezone at the start of the test suite and bring it back the old one at the end?

I tried this solution (so please don't mark this as duplicate): Set browser timezone in a Protractor test

which I found to be a very ugly workaround. Anything prettier?

You could use PowerShell to update the timezone and reset it after. This can be achieved using AppVeyor environment variables , Get-TimeZone & Set-TimeZone . Here is an appveyor.yml sample:

init:
  - ps: $env:ORIGIONAL_TZ = Get-TimeZone
  - ps: Set-TimeZone -Name "Pacific Standard Time"

on_finish:
  - ps: Set-TimeZone -Name $env:ORIGIONAL_TZ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM