Skip to content

Commit 71b58d5

Browse files
committed
fix(mocha): close all processes in mocha user.model test
using gulp, the `user.model` (mongoose) unit test will hang if there are unfinished processes. Closing express and mongoose allows mocha to complete and gulp to continue running
1 parent 12dc418 commit 71b58d5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: app/templates/server/api/user(auth)/user.model.spec(mongooseModels).js

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
import app from '../..';
4+
import mongoose from 'mongoose';
45
import User from './user.model';
56
var user;
67
var genUser = function() {
@@ -27,6 +28,11 @@ describe('User Model', function() {
2728
return User.removeAsync();
2829
});
2930

31+
after(function() {
32+
app.angularFullstack.close();
33+
mongoose.connection.close();
34+
});
35+
3036
it('should begin with no users', function() {
3137
return <%= expect() %>User.findAsync({})<%= to() %>
3238
.eventually.have.length(0);

Diff for: app/templates/server/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require('./routes')(app);
3434

3535
// Start server
3636
function startServer() {
37-
server.listen(config.port, config.ip, function() {
37+
app.angularFullstack = server.listen(config.port, config.ip, function() {
3838
console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
3939
});
4040
}

0 commit comments

Comments
 (0)