Karma can't capture PhantomJS

前端 未结 2 532
梦毁少年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 03:53

    In my case adding

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

    to karma.conf.js was sufficient. The real problem was a very old version of karma (0.12). Now with 1.4. I don't need CPU consuming polling.

    0 讨论(0)
  • 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
    0 讨论(0)
提交回复
热议问题