@@ -452,7 +452,7 @@ w.add('JSON body content-type header', async (result) => {
452
452
result ( res . statusCode === 200 , res . body . toString ( ) )
453
453
} )
454
454
455
- w . add ( 'Ensure that per-request options do not persist within defaults' , async ( result ) => {
455
+ w . add ( 'Ensure that per-request options do not persist between defaults' , async ( result ) => {
456
456
const def = pp . defaults ( {
457
457
'url' : 'http://localhost:5136/testget' ,
458
458
'timeout' : 1000
@@ -467,23 +467,36 @@ w.add('Ensure that per-request options do not persist within defaults', async (r
467
467
result ( r1 . body . toString ( ) === 'hey' && r2 . body . toString ( ) === 'Hi.' , r1 . body . toString ( ) + ' ' + r2 . body . toString ( ) )
468
468
} )
469
469
470
- const runTests = ( ) => {
471
- w . forEach ( ( entry ) => {
472
- const result = ( r , message ) => {
473
- if ( r ) {
474
- console . log ( "OK" , entry [ 0 ] , message )
475
- } else {
476
- console . error ( "Fail" , entry [ 0 ] , message )
477
- }
470
+ let fail = false
471
+
472
+ const runTest = ( i ) => {
473
+ const entry = w [ i ]
474
+ console . log ( i , "running" , entry [ 0 ] )
475
+ const result = ( r , message ) => {
476
+ if ( r ) {
477
+ console . log ( "> OK" , entry [ 0 ] , message )
478
+ } else {
479
+ fail = true
480
+ console . error ( "> Fail" , entry [ 0 ] , message )
478
481
}
479
- if ( entry [ 1 ] . hasOwnProperty ( 'then' ) ) {
480
- entry [ 1 ] ( result ) . catch ( ( err ) => {
481
- console . error ( "Error" , entry [ 0 ] , err )
482
- } )
482
+ if ( w . length > i + 1 ) {
483
+ runTest ( i + 1 )
483
484
} else {
484
- entry [ 1 ] ( result )
485
+ process . exit ( fail ? 1 : 0 )
485
486
}
486
- } )
487
+ }
488
+ if ( entry [ 1 ] . hasOwnProperty ( 'then' ) ) {
489
+ entry [ 1 ] ( result ) . catch ( ( err ) => {
490
+ fail = true
491
+ console . error ( "> Error" , entry [ 0 ] , err )
492
+ } )
493
+ } else {
494
+ entry [ 1 ] ( result )
495
+ }
496
+ }
497
+
498
+ const runTests = ( ) => {
499
+ runTest ( 0 )
487
500
}
488
501
489
502
var httpServer = http . createServer ( httpHandler ) . listen ( 5136 , runTests )
0 commit comments