Skip to content

Commit

Permalink
meanjs#450 Use the error reported by mocha. Added some comments expla…
Browse files Browse the repository at this point in the history
…ining

what's going on in the mocha task.
  • Loading branch information
reblace committed Mar 6, 2015
1 parent 5f57f9d commit ffde5e8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit ffde5e8

Please sign in to comment.