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 {
25912591 *
25922592 * {{> stopRecordingTraffic }}
25932593 */
2594- stopRecordingTraffic ( ) {
2594+ async stopRecordingTraffic ( ) {
2595+ await this . page . setRequestInterception ( false )
25952596 stopRecordingTraffic . call ( this )
25962597 }
25972598
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ async function seeTraffic({
3030 throw new Error ( 'Missing required key "url" in object given to "I.seeTraffic".' ) ;
3131 }
3232
33- if ( ! this . recording || ! this . recordedAtLeastOnce ) {
33+ if ( ! this . recordedAtLeastOnce ) {
3434 throw new Error ( 'Failure in test automation. You use "I.seeTraffic", but "I.startRecordingTraffic" was never called before.' ) ;
3535 }
3636
@@ -66,7 +66,7 @@ async function seeTraffic({
6666}
6767
6868async function grabRecordedNetworkTraffics ( ) {
69- if ( ! this . recording || ! this . recordedAtLeastOnce ) {
69+ if ( ! this . recordedAtLeastOnce ) {
7070 throw new Error ( 'Failure in test automation. You use "I.grabRecordedNetworkTraffics", but "I.startRecordingTraffic" was never called before.' ) ;
7171 }
7272
@@ -107,6 +107,8 @@ async function grabRecordedNetworkTraffics() {
107107function stopRecordingTraffic ( ) {
108108 // @ts -ignore
109109 this . page . removeAllListeners ( 'request' ) ;
110+ // @ts -ignore
111+ this . page . removeAllListeners ( 'requestfinished' ) ;
110112 this . recording = false ;
111113}
112114
Original file line number Diff line number Diff line change @@ -1703,6 +1703,16 @@ module.exports.tests = function () {
17031703 expect ( traffics . length ) . to . equal ( 0 )
17041704 } )
17051705
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+
17061716 it ( 'should see recording traffics' , async ( ) => {
17071717 I . startRecordingTraffic ( )
17081718 I . amOnPage ( 'https://codecept.io/' )
You can’t perform that action at this time.
0 commit comments