@@ -187,6 +187,7 @@ describe('CLI', () => {
187187 ] )
188188 . run ( ) ;
189189 await cli . waitFor ( 'journey/end' ) ;
190+ expect ( await cli . exitCode ) . toBe ( 0 ) ;
190191
191192 const data = safeParse ( cli . buffer ( ) ) ;
192193 const screenshotRef = data . find (
@@ -201,9 +202,7 @@ describe('CLI', () => {
201202
202203 const traceData = data . find ( ( { type } ) => type === 'step/metrics' ) ;
203204 expect ( traceData ) . toBeDefined ( ) ;
204-
205- expect ( await cli . exitCode ) . toBe ( 0 ) ;
206- } , 30000 ) ;
205+ } ) ;
207206
208207 it ( 'override screenshots with `--rich-events` flag' , async ( ) => {
209208 const cli = new CLIMock ( )
@@ -215,10 +214,9 @@ describe('CLI', () => {
215214 ] )
216215 . run ( ) ;
217216 await cli . waitFor ( 'journey/end' ) ;
218- const screenshots = cli
219- . buffer ( )
220- . map ( data => JSON . parse ( data ) )
221- . find ( ( { type } ) => type === 'step/screenshot_ref' ) ;
217+ const screenshots = safeParse ( cli . buffer ( ) ) . find (
218+ ( { type } ) => type === 'step/screenshot_ref'
219+ ) ;
222220 expect ( screenshots ) . not . toBeDefined ( ) ;
223221 expect ( await cli . exitCode ) . toBe ( 0 ) ;
224222 } ) ;
@@ -366,6 +364,8 @@ describe('CLI', () => {
366364 JSON . stringify ( { url : tlsServer . TEST_PAGE } ) ,
367365 '--reporter' ,
368366 'json' ,
367+ '--screenshots' ,
368+ 'off' ,
369369 ] ;
370370 } ) ;
371371
@@ -559,7 +559,7 @@ class CLIMock {
559559 this . data = data . toString ( ) ;
560560 // Uncomment the line below if the process is blocked and you need to see its output
561561 // console.log('CLIMock.stdout:', this.data);
562- this . chunks . push ( ... this . data . split ( '\n' ) . filter ( Boolean ) ) ;
562+ this . chunks . push ( this . data ) ;
563563 if ( this . waitForPromise && this . data . includes ( this . waitForText ) ) {
564564 this . process . stdout . off ( 'data' , dataListener ) ;
565565 this . waitForPromise ( ) ;
@@ -588,6 +588,9 @@ class CLIMock {
588588 }
589589
590590 buffer ( ) {
591- return this . chunks ;
591+ // Merge all the interleaved chunks from stdout and
592+ // split them on new line as synthetics runner writes the
593+ // JSON output in separate lines for every event.
594+ return this . chunks . join ( '' ) . split ( '\n' ) . filter ( Boolean ) ;
592595 }
593596}
0 commit comments