@@ -113,6 +113,10 @@ const defaultConfiguration = {
113113 directAccess : true ,
114114 silent,
115115 logLevel,
116+ liveQuery : {
117+ classNames : [ 'TestObject' ] ,
118+ } ,
119+ startLiveQueryServer : true ,
116120 fileUpload : {
117121 enableForPublic : true ,
118122 enableForAnonymousUser : true ,
@@ -134,6 +138,7 @@ const defaultConfiguration = {
134138 shortLivedAuth : mockShortLivedAuth ( ) ,
135139 } ,
136140 allowClientClassCreation : true ,
141+ encodeParseObjectInCloudFunction : true ,
137142} ;
138143
139144if ( silent ) {
@@ -162,15 +167,15 @@ const destroyAliveConnections = function () {
162167 }
163168} ;
164169// Set up a default API server for testing with default configuration.
165- let server ;
166-
170+ let parseServer ;
167171let didChangeConfiguration = false ;
168172
169173// Allows testing specific configurations of Parse Server
170174const 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 ;
174179 return reconfigureServer ( changedConfiguration ) ;
175180 }
176181 didChangeConfiguration = Object . keys ( changedConfiguration ) . length !== 0 ;
@@ -179,14 +184,20 @@ const reconfigureServer = async (changedConfiguration = {}) => {
179184 port,
180185 } ) ;
181186 cache . clear ( ) ;
182- const parseServer = await ParseServer . startApp ( newConfiguration ) ;
183- server = parseServer . server ;
187+ parseServer = await ParseServer . startApp ( newConfiguration ) ;
184188 Parse . CoreManager . setRESTController ( RESTController ) ;
185189 parseServer . expressApp . use ( '/1' , err => {
186190 console . error ( err ) ;
187191 fail ( 'should not call next' ) ;
188192 } ) ;
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 => {
190201 const key = `${ connection . remoteAddress } :${ connection . remotePort } ` ;
191202 openConnections [ key ] = connection ;
192203 connection . on ( 'close' , ( ) => {
@@ -214,16 +225,12 @@ beforeAll(async () => {
214225 Parse . serverURL = 'http://localhost:' + port + '/1' ;
215226} ) ;
216227
217- beforeEach ( ( ) => {
218- jasmine . DEFAULT_TIMEOUT_INTERVAL = process . env . PARSE_SERVER_TEST_TIMEOUT || 10000 ;
219- } ) ;
220-
221228afterEach ( function ( done ) {
222229 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` ) ;
225233 }
226- destroyAliveConnections ( ) ;
227234 await TestUtils . destroyAllDataPermanently ( true ) ;
228235 SchemaCache . clear ( ) ;
229236 if ( didChangeConfiguration ) {
0 commit comments