gulp-mocha how to pass the compilers flag?

后端 未结 6 1779
隐瞒了意图╮
隐瞒了意图╮ 2021-02-14 10:01

I\'m trying to use the gulp-mocha module but can\'t figure out a good way to pass over the compilers flag. Is there a way to include this in my gulp task? Maybe in a separate

6条回答
  •  -上瘾入骨i
    2021-02-14 10:10

    For anyone trying it now

    gulp.task('test-mocha', function() {
        return gulp.src(['tests/acceptance/*.js'], {read: false})
            .pipe(
                mocha({
                    compilers: 'js:babel-core/register',
                    reporter: 'landing'
                })
            )
            .on('error', gutil.log);
    });
    

    and on top of the gulp file (gulpfile.js)

    var gulp = require('gulp');
    var gutil = require('gulp-util');
    var mocha = require('gulp-mocha');
    var babel = require('babel-register');
    

    run your test and it should work

    gulp test-mocha
    

提交回复
热议问题