forked from approvals/Approvals.NodeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (47 loc) · 1.36 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
'use strict';
const gulp = require('gulp');
const $ = require('gulp-load-plugins')();
const paths = {
mochaTests: ['test/**/*[Tt]ests.js'],
filesToLint: ['./lib/**/*.js', './test/**/*.js', 'gulpfile.js'],
sourceJSFilesForCodeCoverage: ['./lib/**/*.js']
};
gulp.task('lint', function () {
return gulp.src(paths.filesToLint)
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
gulp.task('lint-watch', gulp.series('lint', function () {
$.watch(paths.filesToLint, function () {
gulp.start('lint');
});
}));
gulp.task('unitTest', function() {
return gulp.src(paths.mochaTests, { read: false })
.pipe($.mocha({
reporter: 'spec',
slow: 500,
timeout: 5000,
//globals: {}
}));
})
gulp.task('test', gulp.series('unitTest', 'lint'));
gulp.task('coverage', function (cb) {
gulp.src(paths.sourceJSFilesForCodeCoverage)
.pipe($.istanbul()) // Covering files
.pipe($.istanbul.hookRequire())
.on('finish', function () {
gulp.src(paths.mochaTests, { read: false })
.pipe($.mocha({
reporter: 'dot',
timeout: 5000
}))
.pipe($.istanbul.writeReports()) // Creating the reports after tests ran
.on('finish', function () {
process.chdir(__dirname);
cb();
});
});
});
gulp.task('default', gulp.series("test"));