-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
104 lines (92 loc) · 2.45 KB
/
gulpfile.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'use strict';
var eslint = require('gulp-eslint');
var gulp = require('gulp');
var isparta = require('isparta');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');
gulp.task('lint', function() {
return gulp.src([
'gulpfile.js',
'bin/*',
'lib/**/*.js',
'test/**/*.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('instrument', function () {
return gulp.src([
'lib/**/*.js',
'src/**/*.js'
])
.pipe(istanbul({
includeUntested: true,
// ES6 Instrumentation
instrumenter: isparta.Instrumenter
}))
.pipe(istanbul.hookRequire());
});
function gulp_test() {
var timeout;
var slow;
var argv = require('minimist')(process.argv.slice(2));
var tests = [
'test/**/*.spec.js'
];
// by passing the argument `--sys` you can also run the app tests
// which require spinning up a browser, by default we do not run
// the app tests
if (!argv.sys) {
tests.push('!test/app/**/*.spec.js');
tests.push('!test/npm/**/*.spec.js');
tests.push('!test/examples/**/*.spec.js');
timeout = 20000; // 20s, test timeout
slow = 15000; // 15s, slow warning
} else {
// downloading and running docker containers can take a bit the first
// time around
timeout = 300000; // 5min, test timeout
slow = 240000; // 4min, slow warning
}
return gulp.src(tests)
.pipe(mocha({
log: true,
timeout: timeout,
slow: slow,
reporter: 'spec',
ui: 'bdd',
ignoreLeaks: true,
globals: ['should']
}));
}
gulp.task('test', function() {
return gulp_test();
});
gulp.task('test-coverage', ['instrument'], function() {
var argv = require('minimist')(process.argv.slice(2));
var thresholds;
if (argv.sys) {
thresholds = {
global: {
statements: 95,
branches: 78,
functions: 97,
lines: 95
}
};
} else {
thresholds = {
global: {
statements: 96,
branches: 73,
functions: 100,
lines: 96
}
};
}
return gulp_test()
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({ thresholds: thresholds }));
});
gulp.task('default', ['lint']);