Search code examples
javascriptnode.jstestinggulpnode.js-tape

How do I use gulp with tape?


I'm trying to integrate Gulp with Tape (https://github.com/substack/tape), the NodeJs test harness.

How can I do this? There doesn't seem to be an existing gulp plugin.

I've see this, but it looks really inelegant:

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']);
});

I've tried this, which looks like it should work:

var tape = require('tape');
var spec = require('tap-spec');


gulp.task('test', function() {
    return gulp.src(paths.serverTests, {
            read: false
        })
        .pipe(tape.createStream())
        .pipe(spec())
        .pipe(process.stdout);
});

but I get a TypeError: Invalid non-string/buffer chunk error


Solution

  • Your "inelegant" answer is the best one. Not every problem can be best solved with streams, and using gulp just as a wrapper is not a sin.