UNPKG

882 BJavaScriptView Raw
1"use strict";
2
3var istanbul = require("gulp-istanbul");
4var mocha = require("gulp-mocha");
5
6module.exports = function(gulp, depends, options) {
7 options = options || {};
8 gulp.task("test", depends, function (cb) {
9 gulp.src(["*.js", "lib/**/*.js", "test/*.js"])
10 .pipe(istanbul()) // Covering files
11 .pipe(istanbul.hookRequire()) // Force `require` to return covered files
12 .on("finish", function () {
13 gulp.src(["test/**/test_*.js"], {
14 read: false
15 })
16 .pipe(mocha({
17 reporter: "spec"
18 }))
19 .pipe(istanbul.writeReports()) // Creating the reports after tests runned
20 .pipe(istanbul.enforceThresholds({
21 thresholds: options.coverage && options.coverage.thresholds
22 }))
23 .on("end", cb)
24 .on("error", function(e) {
25 console.error(e.toString());
26 process.exit(1);
27 });
28 });
29 });
30};