sindresorhus / gulp-mocha

Run Mocha tests
MIT License
375 stars 91 forks source link

How to provide the forbid-only flag? #184

Closed k0pernikus closed 6 years ago

k0pernikus commented 6 years ago

In the readme.md it says:

options Options are passed directly to the mocha binary, so you can use any its command-line options in a camelCased form. Arrays are correctly converted to the comma separated list format Mocha expects. Listed below are some of the more commonly used options:

Yet I am unable to provide the mocha flag --forbid-only:

     --forbid-only                           causes test marked with only to fail the suite

In my gulp-file with gulp-mocha I tried to no avail:

mocha(["forbidOnly"])

and just for fun:

mocha({forbidOnly: true}])

Could you please tell me how to provide the forbid-only flag to mocha within the gulpfile?

k0pernikus commented 6 years ago

I was running an outdated version of gulp-mocha. Once I upgraded to 4.0

yarn add gulp-mocha@4

It worked as expected using this syntax:

gulp.task('test', ['pre-test'], function () {
    return gulp.src(['tests/unit/**/*.js'], {read: false})
        .pipe(mocha({forbidOnly: true}));
});