gpt4 book ai didi

javascript - karma : Continuous Integration mode shuts down browser

转载 作者:搜寻专家 更新时间:2023-10-31 23:27:28 27 4
gpt4 key购买 nike

我正在使用 karma 进行我的 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 会阻止浏览器实例关闭。我做错了什么?

最佳答案

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

  • 您使用的是最新版本的 Karma 吗?
  • 在你的情况下, karma 过程是否退出?

关于javascript - karma : Continuous Integration mode shuts down browser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22847742/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com