@@ -3,6 +3,8 @@ const commander = require('../lib/cli/utils/commander').default;
3
3
const definitions = require ( '../lib/cli/definitions/parse-server' ) . default ;
4
4
const liveQueryDefinitions = require ( '../lib/cli/definitions/parse-live-query-server' )
5
5
. default ;
6
+ const path = require ( 'path' ) ;
7
+ const { spawn } = require ( 'child_process' ) ;
6
8
7
9
const testDefinitions = {
8
10
arg0 : 'PROGRAM_ARG_0' ,
@@ -231,3 +233,84 @@ describe('LiveQuery definitions', () => {
231
233
}
232
234
} ) ;
233
235
} ) ;
236
+
237
+ describe ( 'execution' , ( ) => {
238
+ const binPath = path . resolve ( __dirname , '../bin/parse-server' ) ;
239
+ let childProcess ;
240
+
241
+ afterEach ( async ( ) => {
242
+ if ( childProcess ) {
243
+ childProcess . kill ( ) ;
244
+ }
245
+ } ) ;
246
+
247
+ it ( 'shoud start Parse Server' , done => {
248
+ childProcess = spawn ( binPath , [
249
+ '--appId' ,
250
+ 'test' ,
251
+ '--masterKey' ,
252
+ 'test' ,
253
+ '--databaseURI' ,
254
+ 'mongodb://localhost/test' ,
255
+ ] ) ;
256
+ childProcess . stdout . on ( 'data' , data => {
257
+ data = data . toString ( ) ;
258
+ if ( data . includes ( 'parse-server running on' ) ) {
259
+ done ( ) ;
260
+ }
261
+ } ) ;
262
+ childProcess . stderr . on ( 'data' , data => {
263
+ done . fail ( data . toString ( ) ) ;
264
+ } ) ;
265
+ } ) ;
266
+
267
+ it ( 'shoud start Parse Server with GraphQL' , done => {
268
+ childProcess = spawn ( binPath , [
269
+ '--appId' ,
270
+ 'test' ,
271
+ '--masterKey' ,
272
+ 'test' ,
273
+ '--databaseURI' ,
274
+ 'mongodb://localhost/test' ,
275
+ '--mountGraphQL' ,
276
+ ] ) ;
277
+ let output = '' ;
278
+ childProcess . stdout . on ( 'data' , data => {
279
+ data = data . toString ( ) ;
280
+ output += data ;
281
+ if ( data . includes ( 'GraphQL running on' ) ) {
282
+ expect ( output ) . toMatch ( 'parse-server running on' ) ;
283
+ done ( ) ;
284
+ }
285
+ } ) ;
286
+ childProcess . stderr . on ( 'data' , data => {
287
+ done . fail ( data . toString ( ) ) ;
288
+ } ) ;
289
+ } ) ;
290
+
291
+ it ( 'shoud start Parse Server with GraphQL and Playground' , done => {
292
+ childProcess = spawn ( binPath , [
293
+ '--appId' ,
294
+ 'test' ,
295
+ '--masterKey' ,
296
+ 'test' ,
297
+ '--databaseURI' ,
298
+ 'mongodb://localhost/test' ,
299
+ '--mountGraphQL' ,
300
+ '--mountPlayground' ,
301
+ ] ) ;
302
+ let output = '' ;
303
+ childProcess . stdout . on ( 'data' , data => {
304
+ data = data . toString ( ) ;
305
+ output += data ;
306
+ if ( data . includes ( 'Playground running on' ) ) {
307
+ expect ( output ) . toMatch ( 'GraphQL running on' ) ;
308
+ expect ( output ) . toMatch ( 'parse-server running on' ) ;
309
+ done ( ) ;
310
+ }
311
+ } ) ;
312
+ childProcess . stderr . on ( 'data' , data => {
313
+ done . fail ( data . toString ( ) ) ;
314
+ } ) ;
315
+ } ) ;
316
+ } ) ;
0 commit comments