Jags
Jags

Reputation: 1761

Protractor Behind a corporate proxy (angular-cli)

I have a very simple e2e test running on a centos VM that has been running fine. I am getting the following error -

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)

I thought it was due to issues with .waitForAngular() at first, but after stepping back through commits it seems the issue occurred after adding a custom font (making a call outside of our corporate network) - @import url('https://fonts.googleapis.com/css?family=Raleway:400,500,700'); and removing this one line confirms the issue

I can configure the proxy for protractor following this github issue - https://github.com/angular/protractor/issues/124

However it then seems like EVERY call is made via the proxy, including to localhost and now it can not find the Angular app on the localhost.

How to I tell protractor to fetch external resources via the proxy, anything on localhost should ignore the proxy?

Upvotes: 2

Views: 3240

Answers (1)

Jags
Jags

Reputation: 1761

The proxy and proxy bypass has to be configured for the browser running the test. In my case I was using headless chrome, so my protractor.conf.js had the following configuration

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

The important additions were the --proxy-server pointing to my corporate proxy server and the --proxy-bypass-list excluding localhost from the proxy

Upvotes: 2

Related Questions