Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma can't capture PhantomJS

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.

Our server is CentOS 6.4.

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

Any help would be much appreciated!

like image 373
sak_to Avatar asked Jul 03 '13 15:07

sak_to


1 Answers

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']
    }
  );
  };

References

  • Karma is not able to run test cases on phantomJS

  • Karma doesn't exit properly when using public api with the finish callback

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

  • Karma Runner Hangs Indefinitely

  • Preprocessors not running in Jenkins(Linux)
  • "basePath" is relative to "C:\" instead of config file
  • Karma config.js
  • Istanbul/coverage reporter generate LCOV file with relative path for SF parameter instead of absolute path
like image 116
Paul Sweatte Avatar answered Oct 14 '22 13:10

Paul Sweatte