TravisCI失败,无法启动PhantomJS

时间:2014-07-09 12:48:57

标签: node.js phantomjs karma-runner travis-ci

TravisCI似乎无法启动PhantomJS来运行我的Karma / Jasmine测试。这是错误日志:

INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
WARN [watcher]: Pattern "/home/travis/build/fender/dmeapp/config.js" does not match any file.
ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (1/2).
ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (2/2).
ERROR [launcher]: Cannot start PhantomJS

ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.
Warning: Task "karma:continuous" failed. Use --force to continue.

完整版本可以在这里看到:https://travis-ci.org/fender/dmeapp/builds/29499011 存储库可在此处获取:https://github.com/fender/dmeapp

我可以在本地运行测试。也许我需要采取一些额外步骤让PhantomJS在TravisCI实例上可用?

1 个答案:

答案 0 :(得分:1)

您只需要安装karma-phantomjs-launcher,PhantomJS就可以使用Travis。但是,如果您使用Firefox作为测试浏览器,那么您必须包含以下两行:

  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"

总之,这是您必须包含在.travis.yml文件中的内容:

language: node_js
node_js:
  - "0.11"
  - "0.10"

before_script:
  - npm install -g grunt-cli
  - npm install -g bower
  - npm install -g karma
  - npm install karma-phantomjs-launcher -save-dev
  - bower install
  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"