diff --git a/gulpfile.js b/gulpfile.js index ac6c485..5f160fe 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ var jscs = require("gulp-jscs"); var jshint = require("gulp-jshint"); var stylish = require("gulp-jscs-stylish"); var jasmine = require("gulp-jasmine"); +var istanbul = require("gulp-istanbul"); var jsonlint = require("gulp-jsonlint"); var browserify = require("browserify"); var partialify = require("partialify"); @@ -11,6 +12,7 @@ var source = require("vinyl-source-stream"); var jsFiles = [ "./**/*.js", "!node_modules/**/*", + "!coverage/**/*", "!examples/**/node_modules/**/*", "!*/**/*.json", "!./**/*.built.js", @@ -21,6 +23,7 @@ var jsonFiles = [ ".jshintrc", ".jscsrc", "!node_modules/**/*", + "!coverage/**/*", "./**/*.json" ]; @@ -65,6 +68,23 @@ gulp.task("jasmine", function() { })); }); +gulp.task("pre-test", function () { + return gulp.src(["src/**/*.js"]) + // Covering files + .pipe(istanbul()) + // Force `require` to return covered files + .pipe(istanbul.hookRequire()); +}); + +gulp.task("istanbul", ["pre-test"], function () { + return gulp.src(["spec/**/*.js"]) + .pipe(jasmine()) + // Creating the reports after tests ran + .pipe(istanbul.writeReports()) + // Enforce a coverage of at least 90% + .pipe(istanbul.enforceThresholds({ thresholds: { global: 50 } })); +}); + gulp.task("js:prod", createBrowserifyTask({ entries: ["./src/superData.js"], outputFileName: "superdata.js", @@ -163,4 +183,4 @@ gulp.task("watch-test", function() { gulp.watch(jsFiles, ["jasmine"]); }); -gulp.task("test", ["jsonlint", "jshint", "jscs", "jasmine"]); +gulp.task("test", ["jsonlint", "jshint", "jscs", "istanbul"]); diff --git a/package.json b/package.json index a0569c8..6289a9e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.1.12", + "version": "0.1.13", "name": "superdata", "description": "A ligth weight data layer module motivated by extjs' data layer. It can be used with any client-side framework.", "main": "src/superData.js", @@ -56,11 +56,13 @@ "express": "*", "express-logger": "*", "gulp-brfs": "0.1.0", + "gulp-istanbul": "^1.1.0", "gulp-jasmine": "2.4.0", "gulp-jscs": "3.0.2", "gulp-jscs-stylish": "1.3.0", "gulp-jshint": "2.0.0", "gulp-jsonlint": "1.1.2", + "istanbul": "^0.4.5", "jasmine-expect": "1.22.3", "jasmine-reporters": "2.1.1", "jshint": "2.9.1",