Skip to content

Instantly share code, notes, and snippets.

@mikeobrien
Last active August 29, 2015 14:11
Show Gist options
  • Save mikeobrien/ec7470b250a5eadf5621 to your computer and use it in GitHub Desktop.
Save mikeobrien/ec7470b250a5eadf5621 to your computer and use it in GitHub Desktop.
Watching tests with gulp
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
process = require('child_process');
gulp.task('default', ['test', 'lint']);
gulp.task('lint', function() {
return gulp.src(['**/*.js', '!node_modules/**/*'])
.pipe(jshint({ node: true }))
.pipe(jshint.reporter('default'));
});
gulp.task('test', function() {
return gulp.src('test/*.js', { read: false })
.pipe(mocha({ reporter: 'spec' }));
});
gulp.task('watch', function() {
gulp.watch(['test/*.js', 'src/*.js'], function() {
process.spawn('gulp', ['test'], { stdio: 'inherit' });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment