@@ -56,6 +56,24 @@ describe('CLI', () => {
5656 expect ( await cli . exitCode ) . toBe ( 0 ) ;
5757 } ) ;
5858
59+ it ( 'exit with 1 on syntax errors' , async ( ) => {
60+ const cli = new CLIMock ( )
61+ . stdin ( `step('syntax error', async () => {}})` )
62+ . args ( [ '--inline' , '--rich-events' ] )
63+ . run ( ) ;
64+ expect ( await cli . exitCode ) . toBe ( 1 ) ;
65+ } ) ;
66+
67+ it ( 'treat reference error as journey error' , async ( ) => {
68+ const cli = new CLIMock ( )
69+ . stdin ( `apinotfound('fail', async () => {})` )
70+ . args ( [ '--inline' , '--rich-events' ] )
71+ . run ( ) ;
72+ await cli . waitFor ( 'journey/end' ) ;
73+ expect ( cli . output ( ) ) . toContain ( 'apinotfound is not defined' ) ;
74+ expect ( await cli . exitCode ) . toBe ( 0 ) ;
75+ } ) ;
76+
5977 it ( 'does not load a configuration file without a config param' , async ( ) => {
6078 // jest by default sets NODE_ENV to `test`
6179 const original = process . env [ 'NODE_ENV' ] ;
@@ -539,7 +557,7 @@ class CLIMock {
539557 const dataListener = data => {
540558 this . data = data . toString ( ) ;
541559 // Uncomment the line below if the process is blocked and you need to see its output
542- // console.warn( this.data);
560+ // console.log('CLIMock.stdout:', this.data);
543561 this . chunks . push ( ...this . data . split ( '\n' ) . filter ( Boolean ) ) ;
544562 if ( this . waitForPromise && this . data . includes ( this . waitForText ) ) {
545563 this . process . stdout . off ( 'data' , dataListener ) ;
@@ -551,7 +569,7 @@ class CLIMock {
551569 this . exitCode = new Promise ( res => {
552570 // Uncomment to debug stderr
553571 // this.process.stderr.on('data', data => {
554- // console.log('climock .stderr: ', data.toString());
572+ // console.log('CLIMock .stderr:', data.toString());
555573 // });
556574 this . process . on ( 'exit' , code => res ( code ) ) ;
557575 } ) ;
0 commit comments