diff --git a/app/templates/gulpfile.babel(gulp).js b/app/templates/gulpfile.babel(gulp).js index 5b6e9d547..7d6ef7f59 100644 --- a/app/templates/gulpfile.babel(gulp).js +++ b/app/templates/gulpfile.babel(gulp).js @@ -42,8 +42,8 @@ const paths = { scripts: [`${serverPath}/**/!(*.spec|*.integration).js`], json: [`${serverPath}/**/*.json`], test: { - integration: `${serverPath}/**/*.integration.js`, - unit: `${serverPath}/**/*.spec.js` + integration: [`${serverPath}/**/*.integration.js`, 'mocha.global.js'], + unit: [`${serverPath}/**/*.spec.js`, 'mocha.global.js'] } }, karma: 'karma.conf.js', diff --git a/app/templates/mocha.global(gulp).js b/app/templates/mocha.global(gulp).js new file mode 100644 index 000000000..c34b2da8c --- /dev/null +++ b/app/templates/mocha.global(gulp).js @@ -0,0 +1,8 @@ +import app from './';<% if (filters.mongoose) { %> +import mongoose from 'mongoose';<% } %> + +after(function(done) { + app.angularFullstack.on('close', () => done());<% if (filters.mongoose) { %> + mongoose.connection.close();<% } %> + app.angularFullstack.close(); +}); diff --git a/app/templates/server/app.js b/app/templates/server/app.js index 20d4aefe8..c3e2eaefe 100644 --- a/app/templates/server/app.js +++ b/app/templates/server/app.js @@ -34,7 +34,7 @@ require('./routes')(app); // Start server function startServer() { - server.listen(config.port, config.ip, function() { + app.angularFullstack = server.listen(config.port, config.ip, function() { console.log('Express server listening on %d, in %s mode', config.port, app.get('env')); }); }