Last Updated: February 25, 2016
·
1.146K
· rane

Autotest using tape and faucet with gulp

I was looking for a way to run my tests written for tape continuously with gulp and came up with this. Obviously you need to have installed tape and faucet with -g but you'll probably do that anyway. If there's a better way, throw in a comment.

var shell = require('gulp-shell')

gulp.task('exec-tests', shell.task([
  'tape test/* | faucet',
]));

gulp.task('autotest', ['exec-tests'], function() {
  gulp.watch(['app/**/*.js', 'test/**/*.js'], ['exec-tests']);
});

Example:

git:master ❯❯❯ gulp autotest
[gulp] Starting 'exec-tests'...
✓ square2rect
✓ pointInsideRect
✓ doRectsOverlap
# tests 7
# pass  7
✓ ok
[gulp] Finished 'exec-tests' after 138 ms
[gulp] Starting 'autotest'...
[gulp] Finished 'autotest' after 32 ms