如何让circleCI与量角器baseurl一起工作

时间:2016-04-15 06:55:30

标签: angularjs continuous-integration protractor circleci

我正在尝试在CircleCI上设置CI,并在尝试通过baseUrl运行带有测试服务器的Protractor时遇到错误。

protractor protractor/config.js --baseUrl='http://tenant1.my-app.com/' 
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver

/home/ubuntu/my-app/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:365
  onError(new Error(message));
          ^
Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
at ClientRequest.<anonymous> (/home/ubuntu/my-app/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:365:15)
at emitOne (events.js:90:13)
at ClientRequest.emit (events.js:182:7)
at Socket.socketErrorListener (_http_client.js:306:9)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at emitErrorNT (net.js:1249:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

From: Task: WebDriver.createSession()
at acquireSession (/home/ubuntu/my-app/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:62:22)
at Function.createSession (/home/ubuntu/my-app/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:295:12)
at Builder.build (/home/ubuntu/my-app/node_modules/protractor/node_modules/selenium-webdriver/builder.js:458:24)
at [object Object].DriverProvider.getNewDriver (/home/ubuntu/my-app/node_modules/protractor/built/driverProviders/driverProvider.js:42:27)
at [object Object].Runner.createBrowser (/home/ubuntu/my-app/node_modules/protractor/built/runner.js:203:37)
at /home/ubuntu/my-app/node_modules/protractor/built/runner.js:293:21
at _fulfilled (/home/ubuntu/my-app/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/ubuntu/my-app/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/ubuntu/my-app/node_modules/protractor/node_modules/q/q.js:796:13)
at /home/ubuntu/my-app/node_modules/protractor/node_modules/q/q.js:556:49

[launcher] Process exited with error code 1

关于如何让量角器与测试服务器连接的任何想法?

1 个答案:

答案 0 :(得分:0)

您正在设置环境变量错误 - 它不作为标记传递到量角器,它应该在运行命令之前设置为环境变量,例如

命令:

BASE_URL='http://localhost:1337/api/' protractor protractor.conf.js

输出:

[11:09:21] I/launcher - Running 1 instances of WebDriver
[11:09:21] I/hosted - Using the selenium server at http://localhost:4444/wd/hub


  Test describe
>>> env var for process.env.BASE_URL:  http://localhost:1337/api/
    ✓ test case


  1 passing (279ms)

[11:09:24] I/launcher - 0 instance(s) of WebDriver still running
[11:09:24] I/launcher - chrome #01 passed

需要使用基本网址的测试可以通过process.env访问它们:

it('test case', () => {
  console.log('>>> env var for process.env.BASE_URL: ', process.env.BASE_URL);
});

因此,要在基本网址上打开网址,您可以使用量角器的浏览器:

browser.get(process.env.BASE_URL + 'path/to/endpoint');