From 0dd8219c4a1b6c049300722f356a303da516cdf9 Mon Sep 17 00:00:00 2001 From: Alexandre Tuleu Date: Fri, 12 Feb 2016 12:24:31 +0100 Subject: [PATCH] Improves karma config --- gulpfile.js | 19 ++----- package.json | 1 + test/karma.conf.js | 89 +++++++++++++++++++++++--------- test/specs/album-service_test.js | 5 ++ 4 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 test/specs/album-service_test.js diff --git a/gulpfile.js b/gulpfile.js index 209476a..b6bc371 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,23 +1,14 @@ var gulp = require('gulp'); var plugins = require('gulp-load-plugins')({}); +var karma = require('karma'); -gulp.task('test', function() { - console.log(plugins); - return gulp.src('test/karma.conf.js') - .pipe(plugins.karma({ - configFile: 'test/karma.conf.js', - action: 'run' - })) - .on('error', function(err) { - console.log(err); - this.emit('end'); - }); +gulp.task('test', function(done) { + new karma.Server({ + configFile: __dirname + '/test/karma.conf.js' + },done).start(); }); -gulp.task('autotest', function() { - return gulp.watch(['webapp/js/**/*.js','test/specs/*.js'], ['test']); -}); gulp.task('build', function() { diff --git a/package.json b/package.json index 1f531b5..ba24f7f 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "karma-firefox-launcher": "^0.1.7", "karma-jasmine": "^0.3.7", "karma-junit-reporter": "^0.3.8", + "karma-safari-launcher": "^0.1.1", "protractor": "^3.1.1" }, "scripts": { diff --git a/test/karma.conf.js b/test/karma.conf.js index a9976b6..207124d 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -1,30 +1,71 @@ +// Karma configuration +// Generated on Fri Feb 12 2016 12:00:28 GMT+0100 (CET) + module.exports = function(config) { - config.set({ - basepath: './', - files : [ - 'webapp/bower_components/angular/angular.js', - 'webapp/bower_components/angular-route/angular-route.js', - 'webapp/bower_components/angular-mocks/angular-mocks.js', - 'webapp/js/**/*.js', - 'test/specs/**/*.js' - ], + config.set({ - autoWatch: true, + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', - frameworks: ['jasmine'], - browser: ['Chrome'], + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], - plugins : [ - 'karma-chrome-launcher', - 'karma-firefox-launcher', - 'karma-jasmine', - 'karma-junit-reporter' - ], - junitReporter : { - outputFile: 'test_out/unit.xml', - suite: 'unit' - } - }); -}; + // list of files / patterns to load in the browser + files: [ + '../webapp/js/**/*.js', + '../webapp/bower_components/angular*/**/*.js', + 'specs/**/*.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + 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 + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome', 'Safari', 'Firefox'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }) +} diff --git a/test/specs/album-service_test.js b/test/specs/album-service_test.js new file mode 100644 index 0000000..b3749f6 --- /dev/null +++ b/test/specs/album-service_test.js @@ -0,0 +1,5 @@ +describe('Service: albumService', function() { + + + +});