TestCafe, CircleCI 2.0 & SauceLabs — can't get this combination to work

无人久伴 提交于 2019-12-07 22:53:31

问题


So -- I can, from my laptop do the following: testcafe "saucelabs:Chrome@70.0:Windows 10" tests/settings/users.js

This will, connect to SauceLabs, to launch the test (or multiple tests, works either way), to hit back against our development server. (IP's have been whitelisted, it all works).

I can also, of course, login to sauce labs, open a "live testing" browser and connect to this environment/login etc.

Thus, the "SauceLabs =-> My environment" is fine.

If I try to run a build on circleci to do exactly this it fails.

In my role I have the following code:

const getPageHTML = ClientFunction(() => document.documentElement.outerHTML);
let value = await getPageHTML();
console.log(value);
const pageLink = ClientFunction (() => window.location.href);
value = await pageLink();
console.log(value);

This will print out that the entire outerHTML is only

<html><head></head><body></body></html>

It will print out that the current url is "about:blank"

So, my question.. when running tests, using saucelabs, FROM CIRCLE, would I need to whitelist CIRCLE?

I can't seem to figure out what the functional/execution difference is between running the tests from my laptop vs circle when we are USING saucelabs browsers.

Is the "IP from which the tests are being run" (whitelist ip) circleCI at this point, or saucelabs? I, of course, have been presuming it is saucelabs.

NOTE: I actually was able to just take the testcafe "example.js" test, and get it to run using circle/saucelabs. So this literally has something to do with just running the tests back towards my environment. I'd love to learn more about what the "source ip range" would be if circle is running tests "using" saucelab browsers.

Any advice would be greatly appreciated!

(just having a very hard time trying to figure out how to debug/triage the issue)


回答1:


For SauceLabs to exercise an application running within CircleCI containers, you will need to use Sauce's Connect Tunnel since services running inside a CircleCI container are not internet accessible.

CircleCI and SauceLabs partnered to create an "orb" that simplifies the setup of a tunnel. I'm not familiar with TestCafe, but it should solve the connectivity issues.

You can see an example of SauceLabs (though using Maven/Java) in CircleCI here, https://github.com/eddiewebb/demo-blueskygreenbuilds/blob/master/.circleci/config.yml#L17, but basically

  - saucelabs/with_proxy:
      name: "Chrome Tests"
      requires:
        - "Unit Test"
      tunnel_identifier: chrome
      steps:
        - maven/with_cache:
            steps:
              - run: ./mvnw verify -B -Dspring.profiles.active=it -Dsauce.tunnel="chrome" 



回答2:


You need to use Sauce's Connect Tunnel for connection with CircleCI, as @Eddie mentioned in his answer.

The tested site is protected by proxy settings and SauceLabs is whitelisted. The solution is to add CircleCI to your company's white list.

SauceLab browser ===tunnel(ok)===> Testcafe proxy server (CircleCI) ===firewall(fail)===> Site on your machine



来源:https://stackoverflow.com/questions/53653378/testcafe-circleci-2-0-saucelabs-cant-get-this-combination-to-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!