@@ -186,6 +186,7 @@ test('RequestManager.execute timeout error with default maxRetryAttempts', async
186186
187187for ( const statusCode of [ 403 , 442 ] ) {
188188 test ( `RequestManager.execute Request ${ statusCode } error` , async ( ) => {
189+ jest . resetModules ( ) ;
189190 // The await await is just to silence Flow - https://github.com/facebook/flow/issues/6064
190191 const config = await await Config . create ( { } , new Reporter ( ) ) ;
191192 const mockStatusCode = statusCode ;
@@ -203,13 +204,34 @@ for (const statusCode of [403, 442]) {
203204 resolve : body => { } ,
204205 reject : err => {
205206 expect ( err . message ) . toBe (
206- `https://localhost:port/?nocache: Request "https://localhost:port/?nocache" returned a 403 ` ,
207+ `https://localhost:port/?nocache: Request "https://localhost:port/?nocache" returned a ${ statusCode } ` ,
207208 ) ;
208209 } ,
209210 } ) ;
210211 } ) ;
211212}
212213
214+ test ( 'RequestManager.execute propagates non HTTP errors' , async ( ) => {
215+ jest . resetModules ( ) ;
216+ jest . mock ( 'request' , factory => options => {
217+ options . callback ( new Error ( 'bad stuff happened' ) , { } , '' ) ;
218+ return {
219+ on : ( ) => { } ,
220+ } ;
221+ } ) ;
222+ const config = await await Config . create ( { } , new Reporter ( ) ) ;
223+ await config . requestManager . execute ( {
224+ params : {
225+ url : `https://localhost:port/?nocache` ,
226+ headers : { Connection : 'close' } ,
227+ } ,
228+ resolve : body => { } ,
229+ reject : err => {
230+ expect ( err . message ) . toBe ( 'https://localhost:port/?nocache: bad stuff happened' ) ;
231+ } ,
232+ } ) ;
233+ } ) ;
234+
213235test ( 'RequestManager.execute one time password error on npm request' , async ( ) => {
214236 jest . resetModules ( ) ;
215237 jest . mock ( 'request' , factory => options => {
0 commit comments