File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,19 @@ describe('sh mock mode', () => {
103103 const result = await sh ( 'blah' ) ;
104104 expect ( result ) . to . equal ( '' ) ;
105105 } ) ;
106+
107+ it ( 'should make `sh` error if mock exit code is nonzero' , async ( ) => {
108+ sh . mock ( )
109+ . returns ( {
110+ exitCode : 1 ,
111+ stdout : 'here is some output' ,
112+ stderr : 'something went wrong' ,
113+ } ) ;
114+
115+ await expect ( sh ( 'fail' ) ) . to . eventually . be . rejectedWith (
116+ 'Command failed: fail\nsomething went wrong' ,
117+ ) ;
118+ } ) ;
106119 } ) ;
107120
108121 describe ( 'matching mocks' , ( ) => {
@@ -143,6 +156,20 @@ describe('sh mock mode', () => {
143156 const result = await sh ( 'a' ) ;
144157 expect ( result ) . to . equal ( '' ) ;
145158 } ) ;
159+
160+ it ( 'should make `sh` error if mock exit code is nonzero' , async ( ) => {
161+ sh . mock ( )
162+ . command ( 'fail' )
163+ . returns ( {
164+ exitCode : 1 ,
165+ stdout : 'here is some output' ,
166+ stderr : 'something went wrong' ,
167+ } ) ;
168+
169+ await expect ( sh ( 'fail' ) ) . to . eventually . be . rejectedWith (
170+ 'Command failed: fail\nsomething went wrong' ,
171+ ) ;
172+ } ) ;
146173 } ) ;
147174
148175 describe ( 'assertDone' , ( ) => {
You can’t perform that action at this time.
0 commit comments