gulp-mocha icon indicating copy to clipboard operation
gulp-mocha copied to clipboard

gulp-mocha no longer works with many files

Open rogierschouten opened this issue 7 years ago • 4 comments

On Windows, running gulp-mocha with lots of .js files results in a command line too long error:

Error in plugin 'gulp-mocha'
Message:
    spawn undefined ENOENT
Details:
    errno: ENOENT
    code: ENOENT
    syscall: spawn undefined
    killed: false
    stdout:
    stderr: The command line is too long.

    failed: true
    signal: null
   cmd: mocha  <MANY_JS_FILES_LISTED_HERE> --colors
    timedOut: false
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false

This is specific to v4. Downgrading to gulp-mocha version 3.0.1 removes this error.

rogierschouten avatar Mar 08 '17 13:03 rogierschouten

On Mac too.

Message:
    Command failed: mocha <path to spec> --colors
   stderr: 
    failed: true
    signal: null
    cmd: mocha <path to spec> --colors
    timedOut: false

leifdejong avatar Mar 15 '17 08:03 leifdejong

On Windows 10, get same problem. Changing to support long paths in windows, as described here: https://github.com/sindresorhus/gulp-mocha/issues/154#issuecomment-281658710 did not fix it.

Reverting back to 3.0.1 fixed it. Version 4.0.0 broke it again!

jezzsantos avatar Apr 16 '17 21:04 jezzsantos

Unfortunately gulp-mocha version 3.0.1 depends on mocha version 3.0.0, which depends on growl 1.9.2 - which has a security vulnerability (https://github.com/tj/node-growl/issues/60) So downgrading is not an option if you are using a tool to scan your node_modules tree for known vulnerabilities. The issue is still present in gulp-mocha 5.0.0

lgodmer avatar Apr 26 '18 18:04 lgodmer

I've been having trouble with this on Windows 10 too. The solution/workaround I've used is to pass the directory containing the tests to mocha rather than all the files. Mocha will then run all the tests in that directory. If you also use the recursive flag, then mocha will look for tests in subdirectories too.

An example:

var gulp = require('gulp');
var mocha = require('gulp-mocha');

gulp.task('run-tests', function() {
    return gulp.src([ /path/to/directory/ ], { read: false })
        .pipe(mocha({
            recursive: true
        }));
})

nayan92 avatar Jun 22 '18 11:06 nayan92