Skip to content

Commit a320bb1

Browse files
authored
fix: missing requests when recording network (#3834)
1 parent 8cbadf1 commit a320bb1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/helper/Playwright.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,10 @@ class Playwright extends Helper {
27302730

27312731
this.debugSection('REQUEST: ', JSON.stringify(information));
27322732

2733-
information.requestPostData = JSON.parse(information.requestPostData);
2733+
if (typeof information.requestPostData === 'object') {
2734+
information.requestPostData = JSON.parse(information.requestPostData);
2735+
}
2736+
27342737
this.requests.push(information);
27352738
});
27362739
}
@@ -2923,7 +2926,7 @@ class Playwright extends Helper {
29232926
}
29242927

29252928
if (!this.recording || !this.recordedAtLeastOnce) {
2926-
throw new Error('Failure in test automation. You use "I.seeInTraffic", but "I.startRecordingTraffic" was never called before.');
2929+
throw new Error('Failure in test automation. You use "I.seeTraffic", but "I.startRecordingTraffic" was never called before.');
29272930
}
29282931

29292932
for (let i = 0; i <= timeout * 2; i++) {

test/helper/Playwright_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ describe('Playwright', function () {
795795
I.amOnPage('https://codecept.io/');
796796
await I.seeTraffic({ name: 'traffics', url: 'https://codecept.io/img/companies/BC_LogoScreen_C.jpg' });
797797
} catch (e) {
798-
expect(e.message).to.equal('Failure in test automation. You use "I.seeInTraffic", but "I.startRecordingTraffic" was never called before.');
798+
expect(e.message).to.equal('Failure in test automation. You use "I.seeTraffic", but "I.startRecordingTraffic" was never called before.');
799799
}
800800
});
801801

0 commit comments

Comments
 (0)