From ffde5e8067aa1513af2b258a85fb41689b575de3 Mon Sep 17 00:00:00 2001 From: reblace Date: Fri, 6 Mar 2015 15:17:58 -0500 Subject: [PATCH] #450 Use the error reported by mocha. Added some comments explaining what's going on in the mocha task. --- gulpfile.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8fb826c57f..1821796752 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -115,16 +115,21 @@ gulp.task('less', function () { gulp.task('mocha', function (done) { // Open mongoose connections var mongoose = require('./config/lib/mongoose.js'); - var error; + + // Connect mongoose mongoose.connect(function() { + + // Run the tests gulp.src(testAssets.tests.server) .pipe(plugins.mocha({ reporter: 'spec' })) .on('error', function (err) { - error = new Error('Mocha tests failed'); + // If an error occurs, save it + error = err; }).on('end', function() { + // When the tests are done, disconnect mongoose and pass the error state back to gulp mongoose.disconnect(function(){ done(error); });