在 Protractor e2e 测试中设置时区 [英] Setting timezone in Protractor e2e tests

查看:40
本文介绍了在 Protractor e2e 测试中设置时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些处理时区的 Protractor 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 &设置时区.这是一个 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

这篇关于在 Protractor e2e 测试中设置时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆