Karma无法捕获PhantomJS [英] Karma can't capture PhantomJS

查看:772
本文介绍了Karma无法捕获PhantomJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们设置了一个运行Karma的Jenkins CI服务器,目标是PhantomJS。我们通过Grunt运行我们的测试。 Jenkins,Grunt和Phantom都正常运行,Karma似乎启动得很好,但是Karma无法捕获Phantom。我们的脚本在本地运行(OSX)就好了。通过bash或通过Jenkins运行同样的错误:

We've set up a Jenkins CI server running Karma targeting PhantomJS. We're running our tests through Grunt. Jenkins, Grunt, and Phantom are all running correctly, and Karma seems to start up fine, but Karma can't capture Phantom. Our scripts run locally (OSX) just fine. The same error exists running via bash or through Jenkins:

Running "karma:jenkins-unit" (karma) task
[2013-07-03 11:03:12.168] [WARN] config - urlRoot normalized to "/__karma/"
DEBUG [reporter]: Using reporter "dots".
DEBUG [reporter]: Using reporter "junit".
DEBUG [reporter]: Using reporter "coverage".
INFO [karma]: Karma server started at http://localhost:8084/__karma/
INFO [launcher]: Starting browser PhantomJS
DEBUG [launcher]: Creating temp dir at /tmp/testacular-7720703
DEBUG [launcher]: phantomjs /tmp/testacular-7720703/capture.js
INFO [karma]: To run via this server, use "karma run --runner-port 9104"
...
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 0
DEBUG [launcher]: Cleaning temp dir /tmp/testacular-7720703
INFO [launcher]: Trying to start PhantomJS again.
DEBUG [launcher]: Creating temp dir at /tmp/testacular-7720703
DEBUG [launcher]: phantomjs /tmp/testacular-7720703/capture.js
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 0
DEBUG [launcher]: Cleaning temp dir /tmp/testacular-7720703
INFO [launcher]: Trying to start PhantomJS again.
DEBUG [launcher]: Creating temp dir at /tmp/testacular-7720703
DEBUG [launcher]: phantomjs /tmp/testacular-7720703/capture.js
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 0
DEBUG [karma]: PhantomJS failed to capture, aborting the run.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Killing PhantomJS
DEBUG [launcher]: Cleaning temp dir /tmp/testacular-7720703
Warning: Task "karma:jenkins-unit" failed. Use --force to continue.

我们的服务器是CentOS 6.4。

Our server is CentOS 6.4.

这里是我们运行的版本:
grunt-cli v0.1.9
grunt v0.4.1
节点0.10.12和0.8.25。
phantomjs 1.9.1
karma 0.8.6

Here are the versions we have running: grunt-cli v0.1.9 grunt v0.4.1 node 0.10.12 and 0.8.25. phantomjs 1.9.1 karma 0.8.6

任何帮助将非常感激!

推荐答案

karma.conf.js 配置文件中使用轮询代替套接字和绝对路径,而不使用相对路径,以确保目录结构正确遍历,客户端/服务器连接没有外部依赖关系:

Use polling instead of sockets and absolute paths instead of relative paths in the karma.conf.js configuration file to ensure the directory structure is being traversed correctly and the client/server connection has no external dependencies:

module.exports = function(config) 
  {
  var absolute_root = process.cwd() + '/';
  config.set
  (
    {
    // https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files

    files: 
       [
       absolute_root + 'test/Spec/**/*.js',
       absolute_root + 'js/*.js',
       absolute_root + '../libs/jquery.js'
       ],

     usePolling: true,

     transports: ['xhr-polling', 'jsonp-polling'],

     browsers: ['PhantomJS']
    }
  );
  };

参考

使用公共API时,Karma无法正确退出

AngularJS + Socket.IO + karma not working in karma 0.8.5

Karma Runner无限期挂起

这篇关于Karma无法捕获PhantomJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆