Skip to content

Commit

Permalink
fix(gulp:mocha): have tests clean up once complete
Browse files Browse the repository at this point in the history
mocha unit and integration tests will hang unless express (and
optionally mongoose) are closed once the tests are complete
  • Loading branch information
david-mohr committed Jan 6, 2016
1 parent fcad9c1 commit 93dec12
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/templates/gulpfile.babel(gulp).js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions app/templates/mocha.global(gulp).js
Original file line number Diff line number Diff line change
@@ -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();
});
2 changes: 1 addition & 1 deletion app/templates/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
}
Expand Down

0 comments on commit 93dec12

Please sign in to comment.