Skip to content

Commit 9089561

Browse files
committed
Adds ability to skip reconfiguration between tests
1 parent 92f11cb commit 9089561

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

spec/helper.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,31 @@ if (process.env.PARSE_SERVER_TEST_CACHE === 'redis') {
116116
const openConnections = {};
117117
// Set up a default API server for testing with default configuration.
118118
let server;
119+
let reconfigured = false;
119120

120121
// Allows testing specific configurations of Parse Server
121-
const reconfigureServer = changedConfiguration => {
122-
return new Promise((resolve, reject) => {
122+
const reconfigureServer = (changedConfiguration, isBeforeEach) => {
123+
// A new configuration was passed by a test
124+
if (changedConfiguration) {
125+
reconfigured = true;
126+
}
127+
// Trying to reconfigure while the spec didn't change the setup
128+
// Do nothing...
129+
if (isBeforeEach && !reconfigured) {
130+
return;
131+
}
132+
133+
if (isBeforeEach) {
134+
reconfigured = false;
135+
}
136+
return new Promise((_resolve, reject) => {
137+
const resolve = function(result) {
138+
_resolve(result);
139+
}
123140
if (server) {
124141
return server.close(() => {
125142
server = undefined;
126-
reconfigureServer(changedConfiguration).then(resolve, reject);
143+
reconfigureServer(changedConfiguration, isBeforeEach).then(resolve, reject);
127144
});
128145
}
129146
try {
@@ -182,7 +199,7 @@ beforeEach(done => {
182199
return;
183200
}
184201
})
185-
.then(reconfigureServer)
202+
.then(() => reconfigureServer(undefined, true))
186203
.then(() => {
187204
Parse.initialize('test', 'test', 'test');
188205
Parse.serverURL = 'http://localhost:' + port + '/1';

0 commit comments

Comments
 (0)