Created
February 8, 2015 21:03
-
-
Save cgmartin/599fefffd6baa161c615 to your computer and use it in GitHub Desktop.
Node ES6 istanbul, isparta, mocha-co gulpfile example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'); | |
var del = require('del'); | |
var mocha = require('gulp-mocha-co'); | |
var istanbul = require('gulp-istanbul'); | |
var isparta = require('isparta'); | |
var coverageEnforcer = require('gulp-istanbul-enforcer'); | |
var paths = { | |
server: { | |
scripts: ['server/src/**/*.js'], | |
tests: ['server/test/**/*.spec.js'], | |
coverage: 'coverage/server' | |
} | |
}; | |
gulp.task('clean-coverage', function(cb) { | |
del(['coverage'], cb); | |
}); | |
gulp.task('test-coverage-server', ['clean-coverage'], function(cb) { | |
var coverageDir = paths.server.coverage; | |
gulp.src(paths.server.scripts) | |
.pipe(istanbul({ // Covering files | |
instrumenter: isparta.Instrumenter, | |
includeUntested: true | |
})) | |
.pipe(istanbul.hookRequire()) // Force `require` to return covered files | |
.on('finish', function() { | |
gulp.src(paths.server.tests, {read: false}) | |
.pipe(mocha({reporter: 'spec'})) | |
.pipe(istanbul.writeReports({ | |
dir: coverageDir, | |
reportOpts: {dir: coverageDir}, | |
reporters: ['text', 'text-summary', 'json', 'html'] | |
})) | |
.pipe(coverageEnforcer({ | |
thresholds: { | |
statements: 80, | |
branches: 50, | |
lines: 80, | |
functions: 50 | |
}, | |
coverageDirectory: coverageDir, | |
rootDirectory : '' | |
})) | |
.on('end', cb); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, just found your snippet, awesome. Just one question: I get an
Unexpected token
atimport express from 'express';
. Isn't that exactly what isparta should solve :S?