@@ -113,6 +113,10 @@ const defaultConfiguration = {
113
113
directAccess : true ,
114
114
silent,
115
115
logLevel,
116
+ liveQuery : {
117
+ classNames : [ 'TestObject' ] ,
118
+ } ,
119
+ startLiveQueryServer : true ,
116
120
fileUpload : {
117
121
enableForPublic : true ,
118
122
enableForAnonymousUser : true ,
@@ -134,6 +138,7 @@ const defaultConfiguration = {
134
138
shortLivedAuth : mockShortLivedAuth ( ) ,
135
139
} ,
136
140
allowClientClassCreation : true ,
141
+ encodeParseObjectInCloudFunction : true ,
137
142
} ;
138
143
139
144
if ( silent ) {
@@ -162,15 +167,15 @@ const destroyAliveConnections = function () {
162
167
}
163
168
} ;
164
169
// Set up a default API server for testing with default configuration.
165
- let server ;
166
-
170
+ let parseServer ;
167
171
let didChangeConfiguration = false ;
168
172
169
173
// Allows testing specific configurations of Parse Server
170
174
const reconfigureServer = async ( changedConfiguration = { } ) => {
171
- if ( server ) {
172
- await new Promise ( resolve => server . close ( resolve ) ) ;
173
- server = undefined ;
175
+ if ( parseServer ) {
176
+ destroyAliveConnections ( ) ;
177
+ await new Promise ( resolve => parseServer . server . close ( resolve ) ) ;
178
+ parseServer = undefined ;
174
179
return reconfigureServer ( changedConfiguration ) ;
175
180
}
176
181
didChangeConfiguration = Object . keys ( changedConfiguration ) . length !== 0 ;
@@ -179,14 +184,20 @@ const reconfigureServer = async (changedConfiguration = {}) => {
179
184
port,
180
185
} ) ;
181
186
cache . clear ( ) ;
182
- const parseServer = await ParseServer . startApp ( newConfiguration ) ;
183
- server = parseServer . server ;
187
+ parseServer = await ParseServer . startApp ( newConfiguration ) ;
184
188
Parse . CoreManager . setRESTController ( RESTController ) ;
185
189
parseServer . expressApp . use ( '/1' , err => {
186
190
console . error ( err ) ;
187
191
fail ( 'should not call next' ) ;
188
192
} ) ;
189
- server . on ( 'connection' , connection => {
193
+ parseServer . liveQueryServer ?. server ?. on ( 'connection' , connection => {
194
+ const key = `${ connection . remoteAddress } :${ connection . remotePort } ` ;
195
+ openConnections [ key ] = connection ;
196
+ connection . on ( 'close' , ( ) => {
197
+ delete openConnections [ key ] ;
198
+ } ) ;
199
+ } ) ;
200
+ parseServer . server . on ( 'connection' , connection => {
190
201
const key = `${ connection . remoteAddress } :${ connection . remotePort } ` ;
191
202
openConnections [ key ] = connection ;
192
203
connection . on ( 'close' , ( ) => {
@@ -214,16 +225,12 @@ beforeAll(async () => {
214
225
Parse . serverURL = 'http://localhost:' + port + '/1' ;
215
226
} ) ;
216
227
217
- beforeEach ( ( ) => {
218
- jasmine . DEFAULT_TIMEOUT_INTERVAL = process . env . PARSE_SERVER_TEST_TIMEOUT || 10000 ;
219
- } ) ;
220
-
221
228
afterEach ( function ( done ) {
222
229
const afterLogOut = async ( ) => {
223
- if ( Object . keys ( openConnections ) . length > 0 ) {
224
- console . warn ( 'There were open connections to the server left after the test finished' ) ;
230
+ // Jasmine process uses one connection
231
+ if ( Object . keys ( openConnections ) . length > 1 ) {
232
+ console . warn ( `There were ${ Object . keys ( openConnections ) . length } open connections to the server left after the test finished` ) ;
225
233
}
226
- destroyAliveConnections ( ) ;
227
234
await TestUtils . destroyAllDataPermanently ( true ) ;
228
235
SchemaCache . clear ( ) ;
229
236
if ( didChangeConfiguration ) {
0 commit comments