2

I am trying to run mocha with gulp with the configuration existed before. moch.opts has the following line.

--timeout 999999
--ui tdd
--full-trace
--recursive
--compilers js:babel-register

how to add them here :

    gulp.task('test', function() {
        return gulp.src('sampleTest/*.js', { read: false })
            .pipe(mocha());
    });
Kalai
  • 81
  • 1
  • 3

3 Answers3

0

I believe you can either create properties on the options object passed to gulp-mocha or you can just have it read the options file. In my case, I didn't want to duplicate things like --recursive or --require test/_init.js, but I did want to override the reporter, so I use the code shown below:

gulp.task('test', ['compile'], function() {
    return gulp.src([], { read: false })
        .pipe(mocha({
            opts: 'test/mocha.opts',
            reporter: 'min'
        }))
        .on('error', gutil.log);
});

You may want to modify this so that it doesn't assume the default path to test files (e.g. test/*.js), but in my simple case I didn't even need to pass a path to mocha. I'm just using gulp to trigger it (as if I had run on the command line something like mocha --opts test/mocha.opts --reporter min)

jacobq
  • 11,209
  • 4
  • 40
  • 71
0

Options are passed directly to the mocha binary, so you can use any its command-line options in a camelCased form. this is the document link

gulp.task('test', ['compile'], function() {
return gulp.src([], { read: false })
    .pipe(mocha({
        timeout: 999999,
        fullTrace: true,
        reporter: 'min'
    }))
    .on('error', gutil.log);
});
lihome
  • 1
-2

add the setTimeout call after the mocha call

.pipe(mocha(),setTimeout(function() {

}, 999999))
user2347763
  • 469
  • 2
  • 10