File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -2591,7 +2591,8 @@ class Puppeteer extends Helper {
2591
2591
*
2592
2592
* {{> stopRecordingTraffic }}
2593
2593
*/
2594
- stopRecordingTraffic ( ) {
2594
+ async stopRecordingTraffic ( ) {
2595
+ await this . page . setRequestInterception ( false )
2595
2596
stopRecordingTraffic . call ( this )
2596
2597
}
2597
2598
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ async function seeTraffic({
30
30
throw new Error ( 'Missing required key "url" in object given to "I.seeTraffic".' ) ;
31
31
}
32
32
33
- if ( ! this . recording || ! this . recordedAtLeastOnce ) {
33
+ if ( ! this . recordedAtLeastOnce ) {
34
34
throw new Error ( 'Failure in test automation. You use "I.seeTraffic", but "I.startRecordingTraffic" was never called before.' ) ;
35
35
}
36
36
@@ -66,7 +66,7 @@ async function seeTraffic({
66
66
}
67
67
68
68
async function grabRecordedNetworkTraffics ( ) {
69
- if ( ! this . recording || ! this . recordedAtLeastOnce ) {
69
+ if ( ! this . recordedAtLeastOnce ) {
70
70
throw new Error ( 'Failure in test automation. You use "I.grabRecordedNetworkTraffics", but "I.startRecordingTraffic" was never called before.' ) ;
71
71
}
72
72
@@ -107,6 +107,8 @@ async function grabRecordedNetworkTraffics() {
107
107
function stopRecordingTraffic ( ) {
108
108
// @ts -ignore
109
109
this . page . removeAllListeners ( 'request' ) ;
110
+ // @ts -ignore
111
+ this . page . removeAllListeners ( 'requestfinished' ) ;
110
112
this . recording = false ;
111
113
}
112
114
Original file line number Diff line number Diff line change @@ -1703,6 +1703,16 @@ module.exports.tests = function () {
1703
1703
expect ( traffics . length ) . to . equal ( 0 )
1704
1704
} )
1705
1705
1706
+ it ( 'should stop the network recording' , async ( ) => {
1707
+ await I . startRecordingTraffic ( )
1708
+ await I . amOnPage ( 'https://codecept.io/' )
1709
+ await I . stopRecordingTraffic ( )
1710
+ const traffics1 = await I . grabRecordedNetworkTraffics ( )
1711
+ await I . amOnPage ( 'https://codecept.io/' )
1712
+ const traffics2 = await I . grabRecordedNetworkTraffics ( )
1713
+ expect ( traffics2 . length ) . to . equal ( traffics1 . length )
1714
+ } )
1715
+
1706
1716
it ( 'should see recording traffics' , async ( ) => {
1707
1717
I . startRecordingTraffic ( )
1708
1718
I . amOnPage ( 'https://codecept.io/' )
You can’t perform that action at this time.
0 commit comments