Karma:持续集成模式关闭浏览器

时间:2014-04-03 19:58:03

标签: javascript node.js angularjs karma-runner

我使用业力来进行我的angularjs测试。当我运行npm test我的测试被执行,但随后,浏览器关闭。我已经使用Chrome,PhantomJS,Safari和Firefox对其进行了测试。这是我的karma.conf.js

// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html

module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      "app/bower_components/jquery/jquery.js",
      "app/bower_components/es5-shim/es5-shim.js",
      "app/bower_components/angular/angular.js",
      'app/bower_components/angular-mocks/angular-mocks.js',
      // 'app/bower_components/angular-scenario/angular-scenario.js',
      "app/bower_components/json3/lib/json3.min.js",
      "app/bower_components/sass-bootstrap/dist/js/bootstrap.js",
      "app/bower_components/angular-resource/angular-resource.js",
      "app/bower_components/angular-cookies/angular-cookies.js",
      "app/bower_components/angular-sanitize/angular-sanitize.js",
      "app/bower_components/angular-route/angular-route.js",
      "app/bower_components/angular-touch/angular-touch.js",
      "app/bower_components/ngstorage/ngStorage.js",
      "app/bower_components/underscore/underscore.js",
      "app/bower_components/fastclick/lib/fastclick.js",
      'app/scripts/*.js',
      'app/scripts/**/*.js',
      // 'test/mock/**/*.js',
      'test/spec/**/*.js'
    ],

    // list of files / patterns to exclude
    exclude: [],

    // web server port
    port: 8080,

    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false,
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome', 'Firefox', 'Safari', 'PhantomJS'],

    plugins : [
      'karma-junit-reporter',
      'karma-phantomjs-launcher',
      'karma-chrome-launcher',
      'karma-firefox-launcher',
      'karma-script-launcher',
      'karma-jasmine'
    ],

    junitReporter : {
      outputFile: 'test_out/unit.xml',
      suite: 'unit'
    }
  });
};

更改logLevel: config.LOG_DEBUG时,我在终端上获得以下输出:

PhantomJS 1.9.7 (Mac OS X): Executed 1 of 1 SUCCESS (0.007 secs / 0.028 secs)
DEBUG [karma]: Run complete, exitting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Process PhantomJS exited with code 0

我想,singleRun: false会阻止浏览器实例关闭。我做错了什么?

1 个答案:

答案 0 :(得分:0)

我刚刚在我的电脑和Mac上测试了这两种情况,浏览器都没有关闭。此外,如果我关闭Chrome窗口,Karma会立即打开一个新窗口。

  • 您使用的是最新版本的Karma吗?
  • 在你的情况下,业力流程会退出吗?