最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Karma opens three times in Chrome. Karma Bug? - Stack Overflow

programmeradmin0浏览0评论

For some reason, Karma tries three times to open Chrome, and thinks it's unsuccessful. It works fine once it loads, and shows that it connects on two sockets.

I have Chrome installed in a different location than Karma defaults to, so I had to link to the absolute path of Chrome. I suspect this may have something to do with why it doesn't "see" that Chrome is running. Is this a bug or is there something I can do to fix this?

Here is my config:

module.exports = function(config) {
config.set({

// base path, that will be used to resolve files and exclude
basePath: '',


// frameworks to use
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
    '../../Scripts/angular.js',
    '../../Scripts/angular-*.js',
    '*.spec.js',
    '*.js'
],


// list of files to exclude
exclude: [
  '../../Scripts/angular-scenario.js',
],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


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


// 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: ["C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"],

// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};

For some reason, Karma tries three times to open Chrome, and thinks it's unsuccessful. It works fine once it loads, and shows that it connects on two sockets.

I have Chrome installed in a different location than Karma defaults to, so I had to link to the absolute path of Chrome. I suspect this may have something to do with why it doesn't "see" that Chrome is running. Is this a bug or is there something I can do to fix this?

Here is my config:

module.exports = function(config) {
config.set({

// base path, that will be used to resolve files and exclude
basePath: '',


// frameworks to use
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
    '../../Scripts/angular.js',
    '../../Scripts/angular-*.js',
    '*.spec.js',
    '*.js'
],


// list of files to exclude
exclude: [
  '../../Scripts/angular-scenario.js',
],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


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


// 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: ["C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"],

// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
Share Improve this question asked Nov 25, 2013 at 7:09 RyanJMcGowanRyanJMcGowan 1,5151 gold badge16 silver badges33 bronze badges 1
  • still a good question in 2018! – Natrium Commented May 31, 2018 at 5:52
Add a ment  | 

2 Answers 2

Reset to default 2

For me, closing the browser window by pressing the X button would cause this issue to occur. There is a flag called retryLimit which is set to 2 by default, see http://karma-runner.github.io/2.0/config/configuration-file.html.

If you set that to zero, by adding the line

retryLimit : 0,

somewhere in your config.set structure, the browser doesn't pop up after you close it. Though, the fact that that flag exists makes me think that you are normally supposed to close karma by some other means...

I think instead of providing the absolute path, you should set the path to chrome binary in your environmental variables. You can set it manually, or follow the instructions here: http://karma-runner.github.io/2.0/config/browsers.html

发布评论

评论列表(0)

  1. 暂无评论