grafana / xk6-browser

The browser module adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol to k6.
https://grafana.com/docs/k6/latest/javascript-api/k6-browser/
GNU Affero General Public License v3.0
343 stars 41 forks source link

Migrate Request APIs to async #1308

Closed inancgumus closed 4 months ago

inancgumus commented 6 months ago
### Tasks
- [ ] #1348
- [ ] #1349
- [ ] https://github.com/grafana/xk6-browser/pull/1354
- [ ] https://github.com/grafana/xk6-browser/pull/1358
- [ ] https://github.com/grafana/xk6-browser/pull/1363
- [ ] grafana/k6-docs#1603
- [ ] https://github.com/grafana/k6-docs/pull/1614
- [ ] https://github.com/grafana/k6-DefinitelyTyped/pull/55
- [x] Release Notes:

What

Migrate the following APIs according to the How section in #428:

Class Method Current k6 Return PW return
Request allHeaders Record<string,string> Promise<{[key:string]:string;}>
Request headerValue string|null Promise<null|string>
Request headersArray Array<{name:string;value:string}> Promise<Array<{name:string;value:string;}>>
Request postData string null|string
Request resourceType ResourceType string
Request response Response|null Promise<null|Response>
Request size {body:number;headers:number} not found in Playwright
Request timing ResourceTiming {startTime:number;domainLookupStart:number;domainLookupEnd:number;connectStart:number;secureConnectionStart:number;connectEnd:number;requestStart:number;responseStart:number;responseEnd:number;}

For details on the Why and How, check the overarching issue in #428.

allansson commented 4 months ago

The type definitions for this are already async.

inancgumus commented 4 months ago

@allansson Looks like they (Response and Request) are not async? Am I missing something?

https://github.com/grafana/k6-DefinitelyTyped/blob/134104e2c91b1c5d919d700afb79980165039840/types/k6/experimental/browser.d.ts#L3778

allansson commented 4 months ago

Let me double-check. 🤔

allansson commented 4 months ago

My bad. I misread the expected return types of the tests. Will update these and the response types.