Skip to content

Instantly share code, notes, and snippets.

@Swiip
Last active August 29, 2015 14:17
Show Gist options
  • Save Swiip/2dbfd47a8fdf95cf23f9 to your computer and use it in GitHub Desktop.
Save Swiip/2dbfd47a8fdf95cf23f9 to your computer and use it in GitHub Desktop.
'use strict';
module.exports = function(config) {
config.set({
logLevel: config.LOG_INFO,
frameworks: ['jasmine'],
browsers : ['PhantomJS'],
ngHtml2JsPreprocessor: {
stripPrefix: 'src/',
moduleName: 'gulpAngular'
},
plugins : [
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-ng-html2js-preprocessor'
],
preprocessors: {
'src/**/*.html': ['ng-html2js']
}
});
};
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var wiredep = require('wiredep');
var karma = require('karma');
var concat = require('concat-stream');
var _ = require('lodash');
module.exports = function(options) {
function listFiles(callback) {
var bowerDeps = wiredep({
directory: 'bower_components',
exclude: ['bootstrap-sass-official'],
dependencies: true,
devDependencies: true
});
var specFiles = [
options.src + '/**/*.spec.js',
options.src + '/**/*.mock.js'
];
var htmlFiles = [
options.src + '/**/*.html'
];
var srcFiles = [
options.src + '/{app,components}/**/*.js',
].concat(specFiles.map(function(file) {
return '!' + file;
}));
gulp.src(srcFiles)
.pipe($.angularFilesort())
.pipe(concat(function(files) {
callback(bowerDeps.js
.concat(_.pluck(files, 'path'))
.concat(htmlFiles)
.concat(specFiles));
}));
}
function runTests (singleRun, done) {
listFiles(function(files) {
karma.server.start({
configFile: __dirname + '/../karma.conf.js',
files: files,
singleRun: singleRun
}, done);
});
}
gulp.task('test', ['scripts'], function(done) {
runTests(true, done);
});
gulp.task('test:auto', ['watch'], function(done) {
runTests(false, done);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment