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 {
2974
2974
throw new Error ( 'Failure in test automation. You use "I.grabRecordedNetworkTraffics", but "I.startRecordingTraffic" was never called before.' ) ;
2975
2975
}
2976
2976
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
+ }
2987
2986
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 ( ) ,
2991
2992
body,
2992
- } ;
2993
- } ,
2994
- ) ) ;
2995
- await Promise . all ( promises ) ;
2993
+ } ,
2994
+ } ;
2995
+ } ) ;
2996
2996
2997
- return this . requests ;
2997
+ return Promise . all ( promises ) ;
2998
2998
}
2999
2999
3000
3000
/**
Original file line number Diff line number Diff line change @@ -983,6 +983,7 @@ describe('Playwright', function () {
983
983
await I . see ( 'this was another mocked' ) ;
984
984
985
985
const traffics = await I . grabRecordedNetworkTraffics ( ) ;
986
+ await I . grabRecordedNetworkTraffics ( ) ;
986
987
expect ( traffics [ 0 ] . url ) . to . equal ( 'https://reqres.in/api/comments/1' ) ;
987
988
expect ( traffics [ 0 ] . response . status ) . to . equal ( 200 ) ;
988
989
expect ( traffics [ 0 ] . response . body ) . to . contain ( { name : 'this was mocked' } ) ;
You can’t perform that action at this time.
0 commit comments