app + '**/*.js',
'!' + app + '**/*.spec.js'
],
+ jsFilesWithSpecs: [
+ app + '**/*.module.js',
+ app + '**/*.js'
+ ],
jsFilesStubs: [
- bower.directory + 'angular-mocks/angular-mocks.js',
main + 'stubs/**/*.js'
],
index: main + 'index.html',
jshintConfigurationFile: '.jshintrc',
- jscsConfigurationFile: '.jscsrc'
+ jscsConfigurationFile: '.jscsrc',
+
+ karmaConf: 'karma.conf.js'
};
config.getWiredepOptions = function() {
/**
* Arguments:
*
- * --verbose : Various tasks will produce more output to the console.
- * --stubs : Using stubs in index.html (for mocking services, controllers or any other stuff)
+ * [--verbose] : Various tasks will produce more output to the console. No verbose by default.
+ * [--stubs] : Using stubs in index.html (for mocking services, controllers or any other stuff) No stubs by default.
+ * [--environment] : Running tasks in integration or development environment. Development by default.
*/
-
/**
* Default tasks
*
gulp.task('help', plugins.taskListing);
gulp.task('default', ['help']);
-
/**
* vet (evaluate) the code and create coverage report.
*
log('Wiring bower dependencies into html');
var wiredep = require('wiredep').stream;
- var wiredepOptions = config.getWiredepOptions();
-
var jsFiles = args.stubs ? [].concat(config.jsFilesWithoutSpecs, config.jsFilesStubs) : config.jsFilesWithoutSpecs;
return gulp.src(config.index)
- .pipe(wiredep(wiredepOptions))
+ .pipe(wiredep(config.getWiredepOptions()))
.pipe(inject(jsFiles, ''))
.pipe(gulp.dest(config.main));
});
/**
- * Runs HTTP server in development mode.
+ * Runs HTTP server.
*/
-gulp.task('server-dev', ['wiredep'], function() {
- log('Starting server in development mode');
+gulp.task('server', ['wiredep'], function(done) {
+ var environment = 'development';
+
+ if (args.environment) {
+ environment = args.environment;
+ }
- server(true);
+ log('Starting server in ' + environment + ' mode');
+ server(environment);
+ done();
+});
+
+/**
+ * Runs specs once and exit.
+ *
+ * @return {Stream}
+ */
+gulp.task('test', ['vet'], function(done) {
+ startTests(true, done);
+});
+
+/**
+ * Run specs and wait. Watch for file changes and re-run tests on each change
+ */
+gulp.task('autotest', function(done) {
+ startTests(false, done);
});
/**
/**
* Runs HTTP server.
*
- * @param {boolean} isDev - development or build mode.
+ * @param {string=} [environment='development'] development or integration environments.
*/
-function server(isDev) {
+function server(environment) {
var nodeOptions = {
script: serverConfig.script,
delayTime: 1,
env: {
- 'NODE_ENV': isDev ? 'dev' : 'build'
+ 'NODE_ENV': environment ? environment : 'development'
},
watch: [serverConfig.directory]
};
});
}
+/**
+ * Tests runner, karma launcher.
+ *
+ * @param {boolean} singleRun True means run once and end (continuous integration), or keep running (development)
+ * @param {function} done Callback to fire when karma is done
+ * @return {undefined}
+ */
+function startTests(singleRun, done) {
+ var excludeFiles = [];
+ var karma = require('karma').server;
+
+ karma.start({
+ configFile: __dirname + '/karma.conf.js',
+ exclude: excludeFiles,
+ singleRun: singleRun
+ }, doneKarma);
+
+ function doneKarma(result) {
+ log('Karma completed');
+ log('Karma: tests exited with code ' + result);
+ done();
+ }
+}
+
function log(message) {
plugins.util.log(plugins.util.colors.blue(message));
-}
\ No newline at end of file
+}
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/angular-mocks/angular-mocks.js',
//endbower
-
- 'app/**/*.module.js',
- 'app/**/*.js'
+ 'src/showcase/app/**/*.module.js',
+ 'src/showcase/app/**/*.js'
],
// list of files / patterns to exclude
},
preprocessors: {
- 'app/**/*.js': ['coverage']
+ 'src/showcase/app/**/!(*.spec)+(.js)': ['coverage']
},
coverageReporter: {
// specify a common output directory
- dir: 'test-tmp/coverage',
+ dir: 'report/coverage',
reporters: [
// reporters not supporting the `file` property
- { type: 'html', subdir: 'report-html' },
- { type: 'lcov', subdir: 'report-lcov' },
+ {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', subdir: '.', file: 'text-summary.txt' },
+ {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', subdir: '.', file: 'text-summary.txt'}
]
},
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
- logLevel: config.LOG_INFO,
+ logLevel: config.LOG_INFO
// Uncomment the following lines if you are using grunt's server to run the tests
// proxies: {
"gulp-useref": "~1.3.0",
"gulp-util": "~3.0.6",
"jshint-stylish": "~2.0.1",
+ "karma": "~0.13.9",
"karma-coverage": "~0.5.0",
"karma-jasmine": "~0.3.6",
"karma-junit-reporter": "~0.3.3",
"wiredep": "~3.0.0-beta",
"yargs": "~3.19.0"
},
- "config": {
- "backend-port": "8080",
- "express-port": "8081",
- "backend-server-name": "gumartinm.name",
- "backend-server-url": "showcase"
- },
"scripts": {
"prestart": "wiredep -s app/index.html",
"pretest": "wiredep -s karma.conf.js --dependencies --devDependencies",
app.use(logger('dev'));
switch (environment) {
- case 'build':
- console.log('build mode');
+ case 'integration':
+ console.log('integration mode');
- app.use(express.static('./build/'));
+ app.use(express.static('./dist/'));
// Deep linking
- app.use('/*', express.static('./build/index.html'));
+ app.use('/*', express.static('./dist/index.html'));
break;
default:
console.log('development mode');
$stateProvider.state('welcome', welcome);
}
]);
-}());
\ No newline at end of file
+}());
'ui.bootstrap.modal'
]);
-}());
\ No newline at end of file
+}());