From 44add9d6ac3cadfc98d041413bc0b45f24d2b614 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 20 Mar 2016 10:34:55 -0400 Subject: [PATCH] Reduces the number of connections to mongo created --- spec/helper.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/helper.js b/spec/helper.js index 37491dd7..e8cabbb4 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -51,8 +51,15 @@ var server = app.listen(port); // Prevent reinitializing the server from clobbering Cloud Code delete defaultConfiguration.cloud; +var currentConfiguration; // Allows testing specific configurations of Parse Server var setServerConfiguration = configuration => { + // the configuration hasn't changed + if (configuration === currentConfiguration) { + return; + } + DatabaseAdapter.clearDatabaseSettings(); + currentConfiguration = configuration; server.close(); cache.clearCache(); app = express(); @@ -72,17 +79,17 @@ Parse.serverURL = 'http://localhost:' + port + '/1'; Parse.Promise.disableAPlusCompliant(); beforeEach(function(done) { + restoreServerConfiguration(); Parse.initialize('test', 'test', 'test'); + Parse.serverURL = 'http://localhost:' + port + '/1'; Parse.User.enableUnsafeCurrentUser(); done(); }); afterEach(function(done) { - restoreServerConfiguration(); Parse.User.logOut().then(() => { return clearData(); }).then(() => { - DatabaseAdapter.clearDatabaseSettings(); done(); }, (error) => { console.log('error in clearData', error);