unit-tests.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var karma = require('karma');
var pathSrcHtml = [
path.join(conf.paths.src, '/**/*.html')
];
var pathSrcJs = [
path.join(conf.paths.src, '/**/!(*.spec).js')
];
function runTests (singleRun, done) {
var reporters = ['progress'];
var preprocessors = {};
pathSrcHtml.forEach(function(path) {
preprocessors[path] = ['ng-html2js'];
});
if (singleRun) {
pathSrcJs.forEach(function(path) {
preprocessors[path] = ['coverage'];
});
reporters.push('coverage')
}
var localConfig = {
configFile: path.join(__dirname, '/../karma.conf.js'),
singleRun: singleRun,
autoWatch: !singleRun,
reporters: reporters,
preprocessors: preprocessors
};
var server = new karma.Server(localConfig, function(failCount) {
done(failCount ? new Error("Failed " + failCount + " tests.") : null);
})
server.start();
}
gulp.task('test', ['scripts'], function(done) {
runTests(true, done);
});
gulp.task('test:auto', ['watch'], function(done) {
runTests(false, done);
});