@@ -116,14 +116,31 @@ if (process.env.PARSE_SERVER_TEST_CACHE === 'redis') {
116
116
const openConnections = { } ;
117
117
// Set up a default API server for testing with default configuration.
118
118
let server ;
119
+ let reconfigured = false ;
119
120
120
121
// 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
+ }
123
140
if ( server ) {
124
141
return server . close ( ( ) => {
125
142
server = undefined ;
126
- reconfigureServer ( changedConfiguration ) . then ( resolve , reject ) ;
143
+ reconfigureServer ( changedConfiguration , isBeforeEach ) . then ( resolve , reject ) ;
127
144
} ) ;
128
145
}
129
146
try {
@@ -182,7 +199,7 @@ beforeEach(done => {
182
199
return ;
183
200
}
184
201
} )
185
- . then ( reconfigureServer )
202
+ . then ( ( ) => reconfigureServer ( undefined , true ) )
186
203
. then ( ( ) => {
187
204
Parse . initialize ( 'test' , 'test' , 'test' ) ;
188
205
Parse . serverURL = 'http://localhost:' + port + '/1' ;
0 commit comments