Skip to content

fix(gulp): make coverage tests work #1539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/templates/_.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ client/bower_components
dist
/server/config/local.env.js
npm-debug.log
coverage
6 changes: 4 additions & 2 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",<% } %>
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
20 changes: 13 additions & 7 deletions app/templates/gulpfile.babel(gulp).js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -158,16 +159,18 @@ 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,
statements: 80,
branches: 80,
functions: 80
}
}
},
coverageDirectory: './coverage',
rootDirectory : ''
});

/********************
Expand Down Expand Up @@ -417,7 +420,7 @@ gulp.task('test:server', cb => {
'env:test',
'mocha:unit',
'mocha:integration',
//'mocha:coverage',
'mocha:coverage',
cb);
});

Expand Down Expand Up @@ -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', () => {
Expand Down