From d3fd0c00cae8489e3ce59cd879e20a2bf9248a84 Mon Sep 17 00:00:00 2001 From: Andrew Koroluk Date: Thu, 7 Jan 2016 23:13:17 -0500 Subject: [PATCH] fix(gulp): make coverage tests work add `coverage` to .gitignore --- app/templates/_.gitignore | 1 + app/templates/_package.json | 6 ++++-- app/templates/gulpfile.babel(gulp).js | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/templates/_.gitignore b/app/templates/_.gitignore index d5ae65fb7..9fbd89aa0 100644 --- a/app/templates/_.gitignore +++ b/app/templates/_.gitignore @@ -7,3 +7,4 @@ client/bower_components dist /server/config/local.env.js npm-debug.log +coverage diff --git a/app/templates/_package.json b/app/templates/_package.json index f72d5b765..13c47e4e3 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -43,8 +43,7 @@ "gulp-add-src": "^0.2.0", "gulp-angular-templatecache": "^1.7.0", "gulp-autoprefixer": "2.3.1", - "gulp-babel": "^5.1.0", - "gulp-babel-istanbul": "^0.11.0",<% if(filters.ts) { %> + "gulp-babel": "^5.1.0",<% if(filters.ts) { %> "gulp-typescript": "~2.10.0", "gulp-tsd": "~0.0.4", "gulp-tslint": "~4.2.1",<% } %> @@ -54,6 +53,8 @@ "gulp-filter": "^2.0.2", "gulp-imagemin": "^2.2.1", "gulp-inject": "^1.3.1", + "gulp-istanbul": "~0.10.3", + "gulp-istanbul-enforcer": "^1.0.3", "gulp-jscs": "^3.0.2", "gulp-jshint": "^1.11.0", "gulp-livereload": "^3.8.0", @@ -82,6 +83,7 @@ "gulp-scss-lint": "^0.2.1",<% } if(filters.less) { %> "gulp-less": "^3.0.3", "gulp-recess": "^1.1.2",<% } %> + "isparta": "^3.5.3", "utile": "~0.3.0", "nodemon": "^1.3.7", "run-sequence": "^1.1.0", diff --git a/app/templates/gulpfile.babel(gulp).js b/app/templates/gulpfile.babel(gulp).js index 5182ba25a..9aecb6ca6 100644 --- a/app/templates/gulpfile.babel(gulp).js +++ b/app/templates/gulpfile.babel(gulp).js @@ -13,7 +13,8 @@ import {stream as wiredep} from 'wiredep'; import nodemon from 'nodemon'; import {Server as KarmaServer} from 'karma'; import runSequence from 'run-sequence'; -import {protractor, webdriver_update} from 'gulp-protractor';<% if(filters.stylus) { %> +import {protractor, webdriver_update} from 'gulp-protractor'; +import {Instrumenter} from 'isparta';<% if(filters.stylus) { %> import nib from 'nib';<% } %> var plugins = gulpLoadPlugins(); @@ -158,8 +159,8 @@ let mocha = lazypipe() }); let istanbul = lazypipe() - .pipe(plugins.babelIstanbul.writeReports) - .pipe(plugins.babelIstanbul.enforceThresholds, { + .pipe(plugins.istanbul.writeReports) + .pipe(plugins.istanbulEnforcer, { thresholds: { global: { lines: 80, @@ -167,7 +168,9 @@ let istanbul = lazypipe() branches: 80, functions: 80 } - } + }, + coverageDirectory: './coverage', + rootDirectory : '' }); /******************** @@ -417,7 +420,7 @@ gulp.task('test:server', cb => { 'env:test', 'mocha:unit', 'mocha:integration', - //'mocha:coverage', + 'mocha:coverage', cb); }); @@ -600,9 +603,12 @@ gulp.task('copy:server', () => { gulp.task('coverage:pre', () => { return gulp.src(paths.server.scripts) // Covering files - .pipe(plugins.babelIstanbul()) + .pipe(plugins.istanbul({ + instrumenter: Instrumenter, // Use the isparta instrumenter (code coverage for ES6) + includeUntested: true + })) // Force `require` to return covered files - .pipe(plugins.babelIstanbul.hookRequire()); + .pipe(plugins.istanbul.hookRequire()); }); gulp.task('coverage:unit', () => {