Karma can't capture PhantomJS

前端 未结 2 531
梦毁少年i
梦毁少年i 2021-01-12 03:37

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

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 04:00

    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

提交回复
热议问题