codeceptjs / codeceptjs/CodeceptJS

SeeTraffic & Grabbing network traffic not working

Offen
#4,524 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
4.2k
Forks
757
Ø Merge
2 T. 9 Std.
Gemergte PRs (30 T.)
16

Beschreibung

#### What are you trying to achieve?
I am trying to use seeTraffic and grabRecordedNetworkTraffics functions. grab* function is returning array with empty values or each field. seeTraffic is always passing because it is not able to assert on 'requestPostData'

#### What do you get instead?
for grabRecordedNetworkTraffics I am getting empty values like below:

for seeTraffic, it is always passing.

As per my analysis,

1. For grabRecordedNetworkTraffics, startRecordingTraffic() always returning data with _response = null. Which is causing grabRecordedNetworkTraffics to return empty values.

2. For seeTraffic API call, I found that variable 'RequestPostDataObject' inside helper/network/utils.js is stringified but it is being used as object at line number 101 in the file.

> Provide console output if related. Use `--verbose` mode for more details.

```bash
I grab recorded network traffics
Network traffic [
{ url: '', response: { status: '', statusText: '', body: '' } },
{ url: '', response: { status: '', statusText: '', body: '' } }
]
I stop recording traffic
✔ OK in 15331ms
```

```js
I.amOnPage(`http://localhost:3000`);

I.startRecordingTraffic();
I.click('[data-testid="capture-button"]');
I.wait(3);
I.seeTraffic({
name: 'random', // not sure what to put here
url: 'http://localhost:3000/mock-data',
// parameters: { key: 'value' },
requestPostData: {
operations: [
{
//some data
},
],
}
});
const networkTraffic2 = await I.grabRecordedNetworkTraffics();
console.log('Network traffic', networkTraffic2);
```

### Details
I am trying to assert some network API payload so that I can ensure, on submitting a form it is sending the correct data.

* CodeceptJS version: 3.6.3-beta.2
* NodeJS Version: 20.16.0 /16.14.2
* Operating System: Mac
* puppeteer || webdriverio || testcafe version (if related) webdriverio
* Configuration file:

```js
helpers: {
WebDriver: {
url: getBaseUrl(),
browser: 'chrome',
windowSize: '1366x768',
desiredCapabilities: {
chromeOptions: {
args: [
...webDriverAdditionalArgs,
'--no-sandbox',
'--unexpectedAlertBehavior=accept',
'--unhandledPromptBehavior=accept',
],
},
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.