diff --git a/gulpfile.js b/gulpfile.js index d54c49bd..91860607 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,6 +16,7 @@ var uglify = require('gulp-uglify'); var cssmin = require('gulp-cssmin'); var less = require('gulp-less'); var gutil = require('gulp-util'); +var karma = require('gulp-karma'); var del = require('del'); var browserify = require('browserify'); var buffer = require('vinyl-buffer'); @@ -30,6 +31,7 @@ gulp.task('browserifyAppTask', browserifyAppTask); gulp.task('browserifyVendorTask', browserifyVendorTask); gulp.task('copyStaticTask', copyStaticTask); gulp.task('lessTask', lessTask); +gulp.task('testComponentsTask', testComponentsTask); gulp.task('clean', ['cleanTask']); gulp.task('build', ['browserifyAppTask', 'browserifyVendorTask', 'copyStaticTask', 'lessTask']); @@ -92,6 +94,14 @@ function lessTask() { .pipe(gulp.dest(paths.dist + '/css')); }; +function testComponentsTask() { + return gulp.src([]) + .pipe(karma({ configFile: './test/components/karma.conf.js', action: 'run'})) + .on('error', function (err) { + throw err; + }); +}; + // ------------------------------------------------------------------------------------------ Functions function log(err) { diff --git a/package.json b/package.json index ba510b64..dae93b80 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "date-utils": "^1.2.17", "filesize": "^3.1.3", "fs-extra": "^0.23.1", + "karma": "^0.13.9", "lodash": "^3.10.1", "md5": "^2.0.0", "mime": "^1.3.4", @@ -51,11 +52,20 @@ "gulp": "^3.9.0", "gulp-cssmin": "^0.1.7", "gulp-filter": "^3.0.0", + "gulp-karma": "0.0.4", "gulp-less": "^3.0.3", "gulp-uglify": "^1.2.0", "gulp-util": "^3.0.6", "jquery": "^2.1.4", "jquery-form": "^3.50.0", + "karma-browserify": "^4.3.0", + "karma-chai": "^0.1.0", + "karma-mocha": "^0.2.0", + "karma-phantomjs-launcher": "^0.2.1", + "karma-spec-reporter": "0.0.20", + "mocha": "^2.3.2", + "phantomjs": "^1.9.18", + "proxyquireify": "^3.0.0", "run-sequence": "^1.1.2", "vinyl-buffer": "^1.0.0", "vinyl-paths": "^1.0.0", diff --git a/test/components/karma.conf.js b/test/components/karma.conf.js new file mode 100644 index 00000000..b2204b24 --- /dev/null +++ b/test/components/karma.conf.js @@ -0,0 +1,62 @@ +// Karma configuration +module.exports = function (config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '../../', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['browserify', 'mocha', 'chai'], + + + //list of files / patterns to load in the browser + files: [ + { pattern: 'src/js/components/**/*.test.js' }, + { pattern: 'test/views/**/*.test.js' } + ], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + '**/*.test.js': ['browserify'] + }, + + browserify: { + bundleDelay: 1000, + configure: function(bundle) { + bundle.once('prebundle', function() { + bundle.plugin('proxyquireify/plugin'); + }); + }, + debug: true + }, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['spec'], + + // web server port + port: 5000, + + // 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: false, + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); +}; \ No newline at end of file