From c4420e988a79bce7d847982be7c05f2524e32004 Mon Sep 17 00:00:00 2001 From: Vytor Calixto <vytorcalixto@gmail.com> Date: Tue, 4 Oct 2016 10:09:29 -0300 Subject: [PATCH] Add istanbul to gulp task test Closes simcaq/SCRUM#20 --- README.md | 4 ++-- gulpfile.babel.js | 12 +++++++++++- package.json | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 38e66ae5..23841cd6 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ Previous versions of Node.js do not support ECMAScript6, it is recommended to us > nvm use v4.5.0 -4) Install babel and gulp globally +4) Install the global dependencies -> npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint +> npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint istanbul 5) Install project dependencies diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 10fd314a..0ad22595 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -8,6 +8,8 @@ const eslint = require('gulp-eslint'); const mocha = require('gulp-mocha'); +const istanbul = require('gulp-istanbul'); + const nodemon = require('gulp-nodemon'); const Cache = require('gulp-file-cache'); @@ -61,10 +63,18 @@ gulp.task('docco', () => { gulp.task('doc', ['docco']); -gulp.task('test', () => { +gulp.task('pre-test', () => { + return gulp.src(['build/**/*.js', '!build/{test,test/**}']) + .pipe(istanbul()) + .pipe(istanbul.hookRequire()); +}); + +gulp.task('test', ['pre-test'], () => { process.chdir('build'); gulp.src('test/test.js', {read: false}) .pipe(mocha()) + .pipe(istanbul.writeReports()) + .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) .once('error', () => { process.exit(1); }) diff --git a/package.json b/package.json index ed17027d..d477028f 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "gulp-eslint": "^3.0.1", "gulp-file-cache": "0.0.1", "gulp-function": "^1.3.6", + "gulp-istanbul": "^1.1.1", "gulp-jsdoc3": "^0.3.0", "gulp-mocha": "^3.0.1", "gulp-nodemon": "^2.1.0", -- GitLab