I am developing an application which uses Karma as testing tool for executing test cases. The problem is when I try to execute test cases it isn't executing any tests rather it just stuck at a point. When I use this command
grunt test --force
I am getting this result
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/
After that no progress, it just stuck here. Here is my karma.conf.js file
// 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;
What might be the issue here?
When I added a logLevel configuration in my karma.conf.js file I got the following result
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
I resolved it myself by wrapping up all the configuration settings under the module.exports function. Now my karma.conf.js file will look like this;
// 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
});
};
Now all the test cases are executing fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With