From: Gustavo Martin Morcuende Date: Thu, 27 Aug 2015 00:36:18 +0000 (+0200) Subject: gulp-my-tasks: karma.conf.js in root directory of every project X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=bfcef03870dbc463d834638688a13dadeba882c7;p=JavaScriptForFun gulp-my-tasks: karma.conf.js in root directory of every project Better integration with WebStorm --- diff --git a/angularjs/showcase/karma.conf.js b/angularjs/showcase/karma.conf.js new file mode 100644 index 0000000..7adcd44 --- /dev/null +++ b/angularjs/showcase/karma.conf.js @@ -0,0 +1,115 @@ +// Karma configuration +// http://karma-runner.github.io/0.12/config/configuration-file.html +// Generated on 2015-08-16 using +// generator-karma 1.0.0 + +module.exports = function(config) { + 'use strict'; + + config.set({ + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + // base path, that will be used to resolve files and exclude + basePath: '', + + // testing framework to use (jasmine/mocha/qunit/...) + // as well as any additional frameworks (requirejs/chai/sinon/...) + frameworks: [ + 'jasmine' + ], + + // list of files / patterns to load in the browser + files: [ + //bower:js + 'bower_components/angular/angular.js', + 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', + 'bower_components/angular-translate/angular-translate.js', + 'bower_components/angular-ui-router/release/angular-ui-router.js', + 'bower_components/oclazyload/dist/ocLazyLoad.min.js', + 'bower_components/jquery/dist/jquery.js', + 'bower_components/bootstrap/dist/js/bootstrap.js', + 'bower_components/angular-mocks/angular-mocks.js', + //endbower + 'src/showcase/app/**/*.module.js', + 'src/showcase/app/**/*.js' + ], + + // list of files / patterns to exclude + exclude: [ + ], + + // web server port + port: 8080, + + // Start these browsers, currently available: + // - Chrome + // - ChromeCanary + // - Firefox + // - Opera + // - Safari (only Mac) + // - PhantomJS + // - IE (only Windows) + browsers: [ + 'PhantomJS' + ], + + // Which plugins to enable + plugins: [ + 'karma-phantomjs-launcher', + 'karma-jasmine', + 'karma-coverage', + 'karma-junit-reporter' + ], + + // command line argument override the configuration from the config file + reporters: ['progress', 'junit', 'coverage'], + + junitReporter: { + // results will be saved as $outputDir/$browserName.xml + outputDir: 'report', + // if included, results will be saved as $outputDir/$browserName/$outputFile + outputFile: 'test-results.xml' + // suite will become the package name attribute in xml testsuite element + // suite: '' + }, + + preprocessors: { + 'src/showcase/app/**/!(*.spec)+(.js)': ['coverage'] + }, + + coverageReporter: { + // specify a common output directory + dir: 'report/coverage', + reporters: [ + // reporters not supporting the `file` property + {type: 'html', subdir: 'report-html'}, + {type: 'lcov', subdir: 'report-lcov'}, + // reporters supporting the `file` property, use `subdir` to directly + // output them in the `dir` directory + {type: 'cobertura', subdir: '.', file: 'cobertura.txt'}, + {type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt'}, + {type: 'teamcity', subdir: '.', file: 'teamcity.txt'}, + {type: 'text', subdir: '.', file: 'text.txt'}, + {type: 'text-summary'} + ] + }, + + // Continuous Integration mode + // if true, it capture browsers, run tests and exit + singleRun: false, + + colors: true, + + // level of logging + // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG + logLevel: config.LOG_INFO + + // Uncomment the following lines if you are using grunt's server to run the tests + // proxies: { + // '/': 'http://localhost:9000/' + // }, + // URL root prevent conflicts with the site root + // urlRoot: '_karma_' + }); +}; diff --git a/gulp/gulp-my-tasks/tasks/karma.conf.js b/gulp/gulp-my-tasks/tasks/karma.conf.js deleted file mode 100644 index beadff4..0000000 --- a/gulp/gulp-my-tasks/tasks/karma.conf.js +++ /dev/null @@ -1,106 +0,0 @@ -// Karma configuration -// http://karma-runner.github.io/0.12/config/configuration-file.html -// Generated on 2015-08-16 using -// generator-karma 1.0.0 - -module.exports = function(config) { - 'use strict'; - - config.set({ - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - // base path, that will be used to resolve files and exclude - basePath: '', - - // testing framework to use (jasmine/mocha/qunit/...) - // as well as any additional frameworks (requirejs/chai/sinon/...) - frameworks: [ - 'jasmine' - ], - - // list of files / patterns to load in the browser - files: [ - //bower:js - //endbower - ], - - // list of files / patterns to exclude - exclude: [ - ], - - // web server port - port: 8080, - - // Start these browsers, currently available: - // - Chrome - // - ChromeCanary - // - Firefox - // - Opera - // - Safari (only Mac) - // - PhantomJS - // - IE (only Windows) - browsers: [ - 'PhantomJS' - ], - - // Which plugins to enable - plugins: [ - 'karma-phantomjs-launcher', - 'karma-jasmine', - 'karma-coverage', - 'karma-junit-reporter' - ], - - // command line argument override the configuration from the config file - reporters: ['progress', 'junit', 'coverage'], - - junitReporter: { - // results will be saved as $outputDir/$browserName.xml - outputDir: process.cwd() + '/report', - // if included, results will be saved as $outputDir/$browserName/$outputFile - outputFile: 'test-results.xml' - // suite will become the package name attribute in xml testsuite element - // suite: '' - }, - - - preprocessors: { - '/home/gustavo/github/JavaScriptForFun/angularjs/showcase/src/showcase/app/**/!(*.spec)+(.js)': ['coverage'] - }, - - coverageReporter: { - // specify a common output directory - dir: process.cwd() + '/report/coverage', - reporters: [ - // reporters not supporting the `file` property - {type: 'html', subdir: 'report-html'}, - {type: 'lcov', subdir: 'report-lcov'}, - // reporters supporting the `file` property, use `subdir` to directly - // output them in the `dir` directory - {type: 'cobertura', subdir: '.', file: 'cobertura.txt'}, - {type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt'}, - {type: 'teamcity', subdir: '.', file: 'teamcity.txt'}, - {type: 'text', subdir: '.', file: 'text.txt'}, - {type: 'text-summary'} - ] - }, - - // Continuous Integration mode - // if true, it capture browsers, run tests and exit - singleRun: false, - - colors: true, - - // level of logging - // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG - logLevel: config.LOG_INFO - - // Uncomment the following lines if you are using grunt's server to run the tests - // proxies: { - // '/': 'http://localhost:9000/' - // }, - // URL root prevent conflicts with the site root - // urlRoot: '_karma_' - }); -}; diff --git a/gulp/gulp-my-tasks/tasks/tasks.js b/gulp/gulp-my-tasks/tasks/tasks.js index e1415e6..ba71d7c 100644 --- a/gulp/gulp-my-tasks/tasks/tasks.js +++ b/gulp/gulp-my-tasks/tasks/tasks.js @@ -105,6 +105,25 @@ module.exports = function(gulp, customConfig) { * @ngdoc function * * @description + * wire up bower dependencies into karma.conf.js + * + * @returns {Stream} + */ + gulp.task('wireupkarma', function() { + + log('*** Wiring bower dependencies into karma.conf.js ***'); + + var wiredep = require('wiredep').stream; + + return gulp.src(config.karmaConf) + .pipe(wiredep(config.wiredepKarmaOptions)) + .pipe(gulp.dest(currentDir)); + }); + + /** + * @ngdoc function + * + * @description * Runs HTTP server. */ gulp.task('server', function(done) { @@ -128,7 +147,7 @@ module.exports = function(gulp, customConfig) { * * @returns {Stream} */ - gulp.task('test', ['vet'], function(done) { + gulp.task('test', ['vet', 'wireupkarma'], function(done) { log('*** Run tests once ***'); @@ -141,7 +160,7 @@ module.exports = function(gulp, customConfig) { * @description * Run specs and wait. Watch for file changes and re-run tests on each change */ - gulp.task('autotest', function(done) { + gulp.task('autotest', ['wireupkarma'], function(done) { log('*** Run tests and wait ***'); @@ -402,17 +421,10 @@ module.exports = function(gulp, customConfig) { * @returns {undefined} */ function startTests(singleRun, done) { - var wiredep = require('wiredep'); - var bowerFiles = wiredep(config.wiredepKarmaOptions)['js']; var excludeFiles = []; var Server = require('karma').Server; var karma = new Server({ - files: [].concat( - bowerFiles, - process.cwd() + '/src/showcase/app/**/*.module.js', - process.cwd() + '/src/showcase/app/**/*.js' - ), - configFile: __dirname + '/karma.conf.js', + configFile: currentDir + '/karma.conf.js', exclude: excludeFiles, singleRun: singleRun }, doneKarma);