-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathgulpfile.mjs
72 lines (62 loc) · 1.65 KB
/
gulpfile.mjs
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
"use strict";
import gulp from "gulp";
import mocha from 'gulp-mocha';
import eslint from 'gulp-eslint';
import * as gulp_load_plugins from "gulp-load-plugins";
const $ = gulp_load_plugins;
const paths = {
mochaTests: ["test/**/*[Tt]ests.js", "test/**/*[Tt]ests.mjs"],
filesToLint: ["./lib/**/*.ts", "./test/**/*.mts", "gulpfile.mjs"],
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: "mocha-multi-reporters",
reporterOptions: {
configFile: '.mocha-multi-reporters.json',
},
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"));