量角器在企业代理背后(angular-cli)

时间:2018-01-08 04:40:02

标签: angular proxy protractor angular-cli

我在一个运行良好的centos VM上运行了一个非常简单的e2e测试。我收到以下错误 -

webpack: Compiled successfully.
[15:22:42] I/launcher - Running 1 instances of WebDriver
[15:22:42] I/direct - Using ChromeDriver directly...
Jasmine started
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.

  my-app App
     ✗ Should default to login screen
      - Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
      at ontimeout (timers.js:386:11)
      at tryOnTimeout (timers.js:250:5)
  - Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
      at ontimeout (timers.js:386:11)
      at tryOnTimeout (timers.js:250:5)

我认为这最初是由于.waitForAngular()的问题,但在通过提交退回后,似乎在添加自定义字体(在公司网络外部拨打电话)后出现问题 - {{1}并删除这一行确认问题

我可以根据此github问题配置量角器代理 - https://github.com/angular/protractor/issues/124

然而,似乎每次调用都是通过代理进行的,包括对localhost,现在它无法在localhost上找到Angular应用程序。

如何告诉量角器通过代理获取外部资源,localhost上的任何内容都应该忽略代理?

1 个答案:

答案 0 :(得分:0)

必须为运行测试的浏览器配置代理和代理绕过。在我的情况下,我使用无头铬,所以我的protractor.conf.js具有以下配置

capabilities: {
    'browserName': 'chrome',
    chromeOptions: {
      args: [ "--headless", "--disable-gpu", "--window-size=800x600",
      "--proxy-server=http://proxy.example:80",
      "--proxy-bypass-list=http://localhost"]
    }
}

重要的补充是--proxy-server指向我的公司代理服务器,--proxy-bypass-list不包括来自代理的localhost