Run only one mocha test file on change with gulp

I have a standard gulp watchdog and runner for my Node.js / mocha installation;

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 am wondering how to adapt my task (and another) to send only the mocha test, which has changed - so I do not need to wait 20 seconds to run hundreds of tests.

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

I am looking here for an answer or a pseudo-algorithm for a gulp plugin that I could write for this purpose :)

+6
source share
1 answer

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

describe.only() also available

+5
source

Source: https://habr.com/ru/post/982372/


All Articles