2016-07-08 63 views
1

我想通过CircleCI为我的项目使用量角器进行E2E测试。CircleCI量角器等待服务器启动

启动我的服务器需要较长的时间(约2分钟),我让我的测试,下面的错误(这在本地显示在服务器尚未启动):

Failed: Angular could not be found on the page http://test.blah.dev:3000/auth/login : retries looking for angular exceeded 

这里是我的circle.yml

machine: 
    node: 
    version: 5.11.0 
dependencies: 
    post: 
    - npm run serve-dist: # starts the server 
      background: true 
    - sleep 150 # wait for the server to start 
test: 
    pre: 
    - npm install -g protractor 
    - webdriver-manager update 
    - webdriver-manager start: 
      background: true 

我然后运行npm test,它包括命令protractor conf.js

欲数字找出一个更好的方法来等待服务器在CircleCI上启动。有人能告诉我我做错了什么吗?

+0

我想你可能会发现一些有用的[这个很好的答案](http://stackoverflow.com/a/25042323/771848)。 – alecxe

+0

@alecxe我认为'background:true'确保该过程在CircleCI的后台运行(它代替'&')...我仍然无法理解我错在哪里。 – dyang

回答

1

所以事实证明,我的项目设置中还有其他一些步骤,我错过了...特别是,我需要为/etc/hosts文件添加名称,以及一些环境变量连接到我的mongo实例,像这样:

machine: 
    hosts: 
    test.blah.dev: 127.0.0.1 
    environment: 
    MONGOLAB_URL: mongodb://localhost/testdatabase 

所以这是不是等待服务器开始(使用background: truesleep应注意等待的)的问题。