Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run only one mocha test file on change with gulp

I have a standard gulp test watcher and runner for my Node.js/mocha setup;

gulp.task('mocha', function() {
  process.env.NODE_ENV = 'test';

  return gulp.src(['./test/**/*.js'], {read: false})
    .pipe(mocha({
      recursive: true, 
      reporter: 'list', 
      ui: 'bdd'
    })).on('error', gutil.log); 
});

gulp.task('tests', function() {
  gulp.watch(sources.concat(tests), ['mocha']); 
});

I'm wondering how to adapt my watch task (and the other) to only send to mocha the test that has changed - so that I don't have to wait 20 seconds for a hundred tests to run.

I've tried this with fgulp-newer and gulp-cached, but no luck.

I'm looking here for an answer or for a pseudo-algorithm for a gulp plugin I could then write for this purpose :)

like image 800
Zlatko Avatar asked Feb 12 '15 10:02

Zlatko


1 Answers

You can use in your mocha test it.only() to run only one test

describe.only() is available too

like image 181
Sachacr Avatar answered Sep 28 '22 05:09

Sachacr