File tree Expand file tree Collapse file tree 2 files changed +19
-18
lines changed Expand file tree Collapse file tree 2 files changed +19
-18
lines changed Original file line number Diff line number Diff line change @@ -2974,27 +2974,27 @@ class Playwright extends Helper {
29742974      throw  new  Error ( 'Failure in test automation. You use "I.grabRecordedNetworkTraffics", but "I.startRecordingTraffic" was never called before.' ) ; 
29752975    } 
29762976
2977-     const  requests  =  await  this . requests ; 
2978-     const  promises  =  requests . map ( async  ( request )  =>  request . response . then ( 
2979-       async  ( response )  =>  { 
2980-         let  body ; 
2981-         try  { 
2982-           // There's no 'body' for some requests (redirect etc...) 
2983-           body  =  JSON . parse ( ( await  response . body ( ) ) . toString ( ) ) ; 
2984-         }  catch  ( e )  { 
2985-           // only interested in JSON, not HTML responses. 
2986-         } 
2977+     const  promises  =  this . requests . map ( async  ( request )  =>  { 
2978+       const  resp  =  await  request . response ; 
2979+       let  body ; 
2980+       try  { 
2981+         // There's no 'body' for some requests (redirect etc...) 
2982+         body  =  JSON . parse ( ( await  resp . body ( ) ) . toString ( ) ) ; 
2983+       }  catch  ( e )  { 
2984+         // only interested in JSON, not HTML responses. 
2985+       } 
29872986
2988-         request . response  =  { 
2989-           status : response . status ( ) , 
2990-           statusText : response . statusText ( ) , 
2987+       return  { 
2988+         url : resp . url ( ) , 
2989+         response : { 
2990+           status : resp . status ( ) , 
2991+           statusText : resp . statusText ( ) , 
29912992          body, 
2992-         } ; 
2993-       } , 
2994-     ) ) ; 
2995-     await  Promise . all ( promises ) ; 
2993+         } , 
2994+       } ; 
2995+     } ) ; 
29962996
2997-     return  this . requests ; 
2997+     return  Promise . all ( promises ) ; 
29982998  } 
29992999
30003000  /** 
Original file line number Diff line number Diff line change @@ -983,6 +983,7 @@ describe('Playwright', function () {
983983      await  I . see ( 'this was another mocked' ) ; 
984984
985985      const  traffics  =  await  I . grabRecordedNetworkTraffics ( ) ; 
986+       await  I . grabRecordedNetworkTraffics ( ) ; 
986987      expect ( traffics [ 0 ] . url ) . to . equal ( 'https://reqres.in/api/comments/1' ) ; 
987988      expect ( traffics [ 0 ] . response . status ) . to . equal ( 200 ) ; 
988989      expect ( traffics [ 0 ] . response . body ) . to . contain ( {  name : 'this was mocked'  } ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments