Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pass an argument to Gulp to only run a subset of Specs
"use strict";
const gulp = require('gulp'),
mocha = require('gulp-mocha'),
minimist = require('minimist');
const knownOptions = {
string: 'spec',
default: { spec: '*' }
};
const options = minimist(process.argv.slice(2), knownOptions);
gulp.task('test', ['hint'], () => {
return gulp.src([`test/**/${options.spec}Spec.js`], {read: false}) // String interpolation FTW!
.pipe(mocha());
});
gulp.task('default', ['test']);
$ gulp test --spec foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment