Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mocha-multi incompatible with latest mocha (gulp) #26

Closed
corvinrok opened this issue Feb 22, 2017 · 7 comments
Closed

mocha-multi incompatible with latest mocha (gulp) #26

corvinrok opened this issue Feb 22, 2017 · 7 comments

Comments

@corvinrok
Copy link

In the previous version of mocha (gulp-mocha 3.0.1) all was well with the universe and definitions for the mocha-multi reporter could be specified through the "reporterOptions" property sent into mocha. That now seems to be deprecated or something is seriously broken with the latest version of mocha (gulp-mocha 4.0.1). Here is the gulp script which includes my mocha call:

gulp.task('testServer:ci', ['build:server'], function (cb) {
    log('Running Server unit tests...');
    gulp.src(config.servercoveredfiles)
        .pipe($.istanbul({includeUntested: true}))
        .pipe($.istanbul.hookRequire())
        .on('finish', function () {
            var reporterOptions = {
                xunit: config.ci + 'server-ut.xml',
                spec: '-'
            };
            var stream = gulp.src(config.tests, {read: false})
            // do the success/fail reporting on the unit tests
                .pipe($.mocha({
                    ui: 'bdd',
                    reporter: 'mocha-multi',
                    reporterOptions: reporterOptions
                }));
            stream.on('error', function (err) {
                // if the unit tests fail, report the error to the command
                // line and don't do the CI reporting.
                $.util.log($.util.colors.red(err));
                log('Server Unit Tests Failed, exiting...');
                cb();
            });
            // do the CI reporting for Code coverage
            stream.pipe($.istanbul.writeReports({
                dir: config.ccserver,
                reporters: ['text-summary', 'html', 'cobertura']
            }))
                .on('end', function () {
                    log('Server Unit Tests Completed, exiting...');
                    cb();
                });
        });
});

Up until the most recent release of mocha, this worked fine. Now the following error is spewed, declaring that "reporter definitions should be set in the multi shell variable". Here is the full error:

[17:14:20] Error in plugin 'gulp-mocha'
Message:
    spawn undefined ENOENT
Details:
    errno: ENOENT
    code: ENOENT
    syscall: spawn undefined
    killed: false
    stdout: 
    stderr: ERROR: reporter definitions should be set in the `multi` shell variable
eg. `multi='dot=- xunit=file.xml' mocha`

    failed: true
    signal: null
    cmd: mocha C:\git\my-program\ServerSide\test\fileHandler.test.js C:\git\my-program\ServerSide\test\translateData.test.js --colors --ui=bdd --reporter=mocha-multi
    timedOut: false

Seems like something fundamental has changed, or this reporter is now DOA.

Any help?

@glenjamin
Copy link
Owner

gulp-mocha v4 has made a major breaking change (hence the move to v4 from v3), which instead of calling the mocha API programatically, now shells out to run mocha. sindresorhus/gulp-mocha#151

This means that gulp-mocha options can now only be strings, not complex objects.

If you need the old behaviour, i suggest you peg the version to v3. Otherwise, you'll need to use one of the other two methods for configuring which reporters to use.

@charliekassel
Copy link

How is it possible to pass options when commands should be type=destination values?

For context my situation is this:

.pipe(mocha({
  reporter: 'mocha-multi',
  reporterOptions: 'spec=-,mocha-junit-reporter=./_output/junit/report.xml'
}));

which correctly builds the results.xml file to the provided destination path, however mocha-junit-reporter package requires a mochaFile option else it uses the default of ./test-results.xml which get's built as well.

@glenjamin
Copy link
Owner

@charliekassel
Copy link

Thanks for the quick response - I understand from above though that using gulp-mocha v4+ (I'm using ^6.0.0) I can no longer do that as it can only be a string?

@glenjamin
Copy link
Owner

glenjamin commented Jun 19, 2018 via email

@charliekassel
Copy link

This means that gulp-mocha options can now only be strings, not complex objects.

Fair enough, but I'm basing this on your earlier comment.

@glenjamin
Copy link
Owner

Ah yes, I didn't scroll up - I wrote that a long time ago!

I would suggest you experiment until you find options that work using the mocha commandline, and then hopefully those should convert directly to gulp-mocha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants