Angularjs Karma runner执行测试用例时出现问题

Angularjs Karma runner执行测试用例时出现问题,angularjs,karma-runner,Angularjs,Karma Runner,我正在开发一个应用程序,它使用Karma作为执行测试用例的测试工具。问题是,当我尝试执行测试用例时,它没有执行任何测试,而只是停留在某个点上。当我使用这个命令时 grunt test --force 我得到了这个结果 Running "clean:server" (clean) task Running "concurrent:test" (concurrent) task Running "compass:dist" (compass) task Running "compass:s

我正在开发一个应用程序,它使用Karma作为执行测试用例的测试工具。问题是,当我尝试执行测试用例时,它没有执行任何测试,而只是停留在某个点上。当我使用这个命令时

grunt test --force 
我得到了这个结果

Running "clean:server" (clean) task

Running "concurrent:test" (concurrent) task

Running "compass:dist" (compass) task

Running "compass:server" (compass) task

Done, without errors.

Running "connect:test" (connect) task
Warning: Arguments to path.resolve must be strings Used --force, continuing.

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.10.10 server started at http://localhost:9876/
在那之后没有任何进展,它只是停留在这里。这是我的
karma.conf.js
文件

// Karma configuration

// base path, that will be used to resolve files and exclude
basePath = '';
 module.exports = function(config) {
   config.set({
     frameworks: ['jasmine']
   });
 };
// list of files / patterns to load in the browser
files = [
  'bower_components/angular/angular.min.js',
  'bower_components/angular-route/angular-route.js',
  'bower_components/angular-resource/angular-resource.js',
  'bower_components/angular-animate/angular-animate.js',
  'bower_components/angular-sanitize/angular-sanitize.js',
  'bower_components/ng-grid/lib/jquery-1.9.1.js',
  'bower_components/ng-grid/ng-grid-2.0.7.min.js',
  'bower_components/angular-mocks/angular-mocks.js',
  'bower_components/angular-bootstrap/ui-bootstrap.js',
  'bower_components/momentjs/moment.js',
  'bower_components/nprogress/nprogress.js',
  'bower_components/toastr/toastr.js',
  'app/*.js',
  'app/**/*.js',
  '../sinonjs/test.js'
];

// list of files to exclude
exclude = ['app/out.js'];

preprocessors = {
  'app/*.js': 'coverage',
  'app/**/*.js': 'coverage'
};

// test results reporter to use
// possible values: dots || progress || growl
// for test coverage2 
reporters = ['progress', 'coverage'];
coverageReporter = {
  type : 'html',
  dir : 'coverage/'
}

// test results reporter to use
// possible values: dots || progress || growl
//reporters = ['progress'];

// web server port
port = 8080;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
//logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;

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

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 5000;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;
这里可能有什么问题

当我在
karma.conf.js
文件中添加
logLevel
配置时,我得到了以下结果

Running "clean:server" (clean) task

Running "concurrent:test" (concurrent) task

Running "compass:dist" (compass) task

Running "compass:server" (compass) task

Done, without errors.

Running "connect:test" (connect) task
Warning: Arguments to path.resolve must be strings Used --force, continuing.

Running "karma:unit" (karma) task
DEBUG [plugin]: Loading karma-* from E:\wamp\www\balto4forms\node_modules
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-chrome
-launcher.
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-coffee
-preprocessor.
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-firefo
x-launcher.
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-html2j
s-preprocessor.
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-jasmin
e.
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-phanto
mjs-launcher.
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-requir
ejs.
DEBUG [plugin]: Loading plugin E:\wamp\www\balto4forms\node_modules/karma-script
-launcher.
INFO [karma]: Karma v0.10.10 server started at http://localhost:9876/
DEBUG [watcher]: Resolved files:
        E:/wamp/www/balto4forms/node_modules/karma-jasmine/lib/jasmine.js
        E:/wamp/www/balto4forms/node_modules/karma-jasmine/lib/adapter.js

我自己解决了这个问题,在
模块.exports
功能下完成了所有配置设置。现在我的
karma.conf.js
文件如下所示

// Karma configuration

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

 module.exports = function(config) {
   config.set({
   basePath : '',
     frameworks: ['jasmine'],
     logLevel: config.LOG_INFO,
// list of files / patterns to load in the browser
files : [
  'bower_components/angular/angular.min.js',
  'bower_components/angular-route/angular-route.js',
  'bower_components/angular-resource/angular-resource.js',
  'bower_components/angular-animate/angular-animate.js',
  'bower_components/angular-sanitize/angular-sanitize.js',
  'bower_components/ng-grid/lib/jquery-1.9.1.js',
  'bower_components/ng-grid/ng-grid-2.0.7.min.js',
  'bower_components/angular-mocks/angular-mocks.js',
  'bower_components/angular-bootstrap/ui-bootstrap.js',
  'bower_components/momentjs/moment.js',
  'bower_components/nprogress/nprogress.js',
  'bower_components/toastr/toastr.js',
  'app/*.js',
  'app/**/*.js',
  '../sinonjs/test.js'
],

// list of files to exclude
exclude : ['app/out.js'],

preprocessors : {
  'app/*.js': 'coverage',
  'app/**/*.js': 'coverage',
},

// test results reporter to use
// possible values: dots || progress || growl
// for test coverage2 
reporters : ['progress', 'coverage'],
coverageReporter : {
  type : 'html',
  dir : 'coverage/'
},

// test results reporter to use
// possible values: dots || progress || growl
//reporters : ['progress'];

// web server port
port : 8080,

// cli runner port
runnerPort : 9100,

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

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
//logLevel : LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch : false,

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

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

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

现在所有的测试用例都可以正常执行了。

尝试将配置选项添加到karma.conf.js中;我收到警告警告[config]:不再支持日志信息。请改用
config.LOG\u INFO
并停留在上面的同一行,我认为这是在告诉您在配置中添加这样一行:
logLevel:config.LOG\u DEBUG
(注意,您可能希望调试输出获得最详细的信息)但是测试用例仍然没有执行,这不应该解决任何问题:)它是为了让您能够尝试并找出问题所在。您是否因此获得了额外的输出?