-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
62 lines (54 loc) · 1.46 KB
/
gulpfile.js
File metadata and controls
62 lines (54 loc) · 1.46 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
53
54
55
56
57
58
59
60
61
62
const gulp = require('gulp');
const jasmine = require('gulp-jasmine');
const istanbul = require('gulp-istanbul');
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
const argv = require('minimist')(process.argv.slice(2));
let srcs = gulp.src([
// 'server/middleware/*.js',
// 'server/middleware/**/*.js',
'lib/**/*.js',
'common/models/*.js',
]);
let all = gulp.src('test/spec/test-*.js');
function setupEnvVars() {
process.env.NODE_ENV = 'test';
}
function buildCoverage() {
return srcs.pipe(istanbul())
.pipe(istanbul.hookRequire());
}
function runSpecs() {
let spec;
let toJasmine = jasmine({
reporter: new SpecReporter({
displayStacktrace: 'summary',
}),
timeout: 5 * 1000,
});
if (argv.filter || argv.f) {
spec = gulp.src(`test/spec/test\-${argv.filter || argv.f}*.js`)
.pipe(toJasmine);
if (argv.coverage || argv.c) {
spec = spec.pipe(istanbul.writeReports());
}
} else {
spec = all.pipe(toJasmine)
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({
thresholds: {global: 30},
}));
}
return spec.on('end', function() {
process.exit(0);
}).on('error', function(err) {
console.log(err);
process.exit(1);
});
}
gulp.task('setupEnvVars', setupEnvVars);
gulp.task('build-coverage', buildCoverage);
gulp.task('specs', ['build-coverage', 'setupEnvVars'], runSpecs);
// handle errors
gulp.on('error', function(err) {
process.exit(1);
});