在量角器e2e测试中设置时区
我有一些有关时区的量角器e2e测试。
在我的本地计算机上通过,而在Appveyor上没有通过。
I have some Protractor e2e tests in which I deal with timezone. On my local machine they pass, on Appveyor they don't.
我发现这是一个时区设置问题(Appveyor上的不同设置)。
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?
您可以使用PowerShell来更新时区并在之后重置它。可以使用 AppVeyor环境变量, Get-TimeZone & Set-TimeZone 。这是一个 appveyor.yml
示例:
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