Karma: continuous integration mode disables the browser

I use karma for my angularjs test. When I run npm test, my tests run, but then the browser shuts down. I tested it with Chrome, PhantomJS, Safari and Firefox. Here is mine karma.conf.js.

// Karma configuration
// http://karma-runner.imtqy.com/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'
    }
  });
};

When changing, logLevel: config.LOG_DEBUGI get the following output on my terminal:

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

I thought that would singleRun: falsenot allow closing the browser instance. What am I doing wrong?

+4
source share
1 answer

I just tested this on my PC and on my Mac, and in both cases the browser does not close. Moreover, if I close the Chrome window, Karma will immediately open a new one.

  • ?
  • ?
0

Source: https://habr.com/ru/post/1534911/


All Articles