@types/k6 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k6/README.md +1 -1
- k6/browser/index.d.ts +83 -0
- k6/package.json +3 -3
- k6/{experimental/websockets → websockets}/index.d.ts +16 -17
k6/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for k6 (https://grafana.com/docs/k6/lates
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated: Tue,
|
|
11
|
+
* Last updated: Tue, 10 Feb 2026 09:47:03 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
k6/browser/index.d.ts
CHANGED
|
@@ -4891,6 +4891,39 @@ export interface Page {
|
|
|
4891
4891
|
*/
|
|
4892
4892
|
on(event: "response", listener: (response: Response) => void): void;
|
|
4893
4893
|
|
|
4894
|
+
/**
|
|
4895
|
+
* Registers a handler function to listen for network requests that
|
|
4896
|
+
* fail to reach the server (DNS errors, connection refused, timeouts, etc.).
|
|
4897
|
+
* The handler will receive an instance of {@link Request}, which includes
|
|
4898
|
+
* information about the failed request.
|
|
4899
|
+
*
|
|
4900
|
+
* **Usage**
|
|
4901
|
+
*
|
|
4902
|
+
* ```js
|
|
4903
|
+
* page.on('requestfailed', request => {
|
|
4904
|
+
* const failure = request.failure();
|
|
4905
|
+
* console.log(`Request failed: ${request.url()}`);
|
|
4906
|
+
* console.log(` Error: ${failure ? failure.errorText : 'unknown'}`);
|
|
4907
|
+
* });
|
|
4908
|
+
* ```
|
|
4909
|
+
*/
|
|
4910
|
+
on(event: "requestfailed", listener: (request: Request) => void): void;
|
|
4911
|
+
|
|
4912
|
+
/**
|
|
4913
|
+
* Registers a handler function to listen for network requests that
|
|
4914
|
+
* successfully complete (receive a response). The handler will receive an
|
|
4915
|
+
* instance of {@link Request}, which includes information about the request.
|
|
4916
|
+
*
|
|
4917
|
+
* **Usage**
|
|
4918
|
+
*
|
|
4919
|
+
* ```js
|
|
4920
|
+
* page.on('requestfinished', request => {
|
|
4921
|
+
* console.log(`Request finished: ${request.method()} ${request.url()}`);
|
|
4922
|
+
* });
|
|
4923
|
+
* ```
|
|
4924
|
+
*/
|
|
4925
|
+
on(event: "requestfinished", listener: (request: Request) => void): void;
|
|
4926
|
+
|
|
4894
4927
|
/**
|
|
4895
4928
|
* Returns the page that opened the current page. The first page that is
|
|
4896
4929
|
* navigated to will have a null opener.
|
|
@@ -4990,6 +5023,37 @@ export interface Page {
|
|
|
4990
5023
|
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
4991
5024
|
}): Promise<Response | null>;
|
|
4992
5025
|
|
|
5026
|
+
/**
|
|
5027
|
+
* Goes back to the previous page in the history.
|
|
5028
|
+
*
|
|
5029
|
+
* @example
|
|
5030
|
+
* ```js
|
|
5031
|
+
* await page.goto('https://example.com');
|
|
5032
|
+
* await page.goto('https://example.com/page2');
|
|
5033
|
+
* await page.goBack(); // Will navigate back to the first page
|
|
5034
|
+
* ```
|
|
5035
|
+
*
|
|
5036
|
+
* @param options Navigation options.
|
|
5037
|
+
* @returns A promise that resolves to the response of the requested navigation when it happens.
|
|
5038
|
+
* Returns null if there is no previous entry in the history.
|
|
5039
|
+
*/
|
|
5040
|
+
goBack(options?: NavigationOptions): Promise<Response | null>;
|
|
5041
|
+
|
|
5042
|
+
/**
|
|
5043
|
+
* Goes forward to the next page in the history.
|
|
5044
|
+
*
|
|
5045
|
+
* @example
|
|
5046
|
+
* ```js
|
|
5047
|
+
* await page.goBack(); // Navigate back first
|
|
5048
|
+
* await page.goForward(); // Then navigate forward
|
|
5049
|
+
* ```
|
|
5050
|
+
*
|
|
5051
|
+
* @param options Navigation options.
|
|
5052
|
+
* @returns A promise that resolves to the response of the requested navigation when it happens.
|
|
5053
|
+
* Returns null if there is no next entry in the history.
|
|
5054
|
+
*/
|
|
5055
|
+
goForward(options?: NavigationOptions): Promise<Response | null>;
|
|
5056
|
+
|
|
4993
5057
|
/**
|
|
4994
5058
|
* Adds a route to the page to modify network requests made by that page.
|
|
4995
5059
|
*
|
|
@@ -6003,6 +6067,25 @@ export interface Request {
|
|
|
6003
6067
|
* @returns request URL
|
|
6004
6068
|
*/
|
|
6005
6069
|
url(): string;
|
|
6070
|
+
|
|
6071
|
+
/**
|
|
6072
|
+
* Returns the failure info for a failed request, or null if the request succeeded.
|
|
6073
|
+
* This method returns information about network failures such as DNS errors,
|
|
6074
|
+
* connection refused, timeouts, etc. It does not return information for HTTP
|
|
6075
|
+
* 4xx/5xx responses, which are successful network requests.
|
|
6076
|
+
* @returns The failure information or null if the request succeeded.
|
|
6077
|
+
*/
|
|
6078
|
+
failure(): RequestFailure | null;
|
|
6079
|
+
}
|
|
6080
|
+
|
|
6081
|
+
/**
|
|
6082
|
+
* RequestFailure contains information about a failed request.
|
|
6083
|
+
*/
|
|
6084
|
+
export interface RequestFailure {
|
|
6085
|
+
/**
|
|
6086
|
+
* The error text describing why the request failed.
|
|
6087
|
+
*/
|
|
6088
|
+
errorText: string;
|
|
6006
6089
|
}
|
|
6007
6090
|
|
|
6008
6091
|
/**
|
k6/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/k6",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "TypeScript definitions for k6",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"./experimental/fs": "./experimental/fs/index.d.ts",
|
|
64
64
|
"./experimental/redis": "./experimental/redis/index.d.ts",
|
|
65
65
|
"./experimental/streams": "./experimental/streams/index.d.ts",
|
|
66
|
-
"./
|
|
66
|
+
"./websockets": "./websockets/index.d.ts",
|
|
67
67
|
"./package.json": "./package.json"
|
|
68
68
|
},
|
|
69
69
|
"repository": {
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"scripts": {},
|
|
75
75
|
"dependencies": {},
|
|
76
76
|
"peerDependencies": {},
|
|
77
|
-
"typesPublisherContentHash": "
|
|
77
|
+
"typesPublisherContentHash": "80b31eb39ecab6afca265e96b2a78fd11aa9904f1e43aca2188ce7631b0d7e2c",
|
|
78
78
|
"typeScriptVersion": "5.2"
|
|
79
79
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ReadableStream } from "../experimental/streams/index.js";
|
|
2
|
+
import { CookieJar } from "../http/index.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* This module provides
|
|
6
|
-
* for k6.
|
|
5
|
+
* This module provides a WebSocket API for k6.
|
|
7
6
|
*
|
|
8
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
7
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -43,7 +42,7 @@ export class WebSocket {
|
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
44
|
* The Websocket constructor returns a newly created WebSocket object.
|
|
46
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
45
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/
|
|
47
46
|
*
|
|
48
47
|
* @param url - The URL to which to connect; this should be the URL to which the WebSocket server will respond.
|
|
49
48
|
* @param protocols - Either a single protocol string or an array of protocol strings. The param is reserved for future use and will be presently ignored.
|
|
@@ -53,7 +52,7 @@ export class WebSocket {
|
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
54
|
* Enqueues data to be transmitted to the server over the WebSocket connection.
|
|
56
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
55
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-send/
|
|
57
56
|
*
|
|
58
57
|
* @param data - the data to send to the server
|
|
59
58
|
*/
|
|
@@ -62,7 +61,7 @@ export class WebSocket {
|
|
|
62
61
|
/**
|
|
63
62
|
* Bind event names to event handlers to be executed when their
|
|
64
63
|
* respective event is received by the server.
|
|
65
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
64
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-addeventlistener/
|
|
66
65
|
*
|
|
67
66
|
* @param event - the event to listen for
|
|
68
67
|
* @param listener - the callback to invoke when the event is emitted
|
|
@@ -71,7 +70,7 @@ export class WebSocket {
|
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
72
|
* Closes the WebSocket connection or connection attempt, if any.
|
|
74
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
73
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-close/
|
|
75
74
|
*
|
|
76
75
|
* @param code - An integer WebSocket connection close code value indicating a reason for closure.
|
|
77
76
|
* @param reason - A human-readable string WebSocket connection close reason. No longer than 123 bytes of UTF-8 text.
|
|
@@ -80,13 +79,13 @@ export class WebSocket {
|
|
|
80
79
|
|
|
81
80
|
/**
|
|
82
81
|
* Sends a ping message over the WebSocket connection.
|
|
83
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
82
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-ping/
|
|
84
83
|
*/
|
|
85
84
|
ping(): void;
|
|
86
85
|
|
|
87
86
|
/**
|
|
88
87
|
* Sets an event handler which is invoked when a message event happens.
|
|
89
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
88
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-onmessage/
|
|
90
89
|
*
|
|
91
90
|
* @param event - the message event
|
|
92
91
|
*/
|
|
@@ -94,19 +93,19 @@ export class WebSocket {
|
|
|
94
93
|
|
|
95
94
|
/**
|
|
96
95
|
* Sets an event handler which is invoked when the WebSocket connection's opens.
|
|
97
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
96
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-onopen/
|
|
98
97
|
*/
|
|
99
98
|
onopen: () => void;
|
|
100
99
|
|
|
101
100
|
/**
|
|
102
101
|
* Sets an event handler which is invoked when the WebSocket connection's closes.
|
|
103
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
102
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-onclose/
|
|
104
103
|
*/
|
|
105
104
|
onclose: () => void;
|
|
106
105
|
|
|
107
106
|
/**
|
|
108
107
|
* Sets an event handler which is invoked when errors occur.
|
|
109
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
108
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-onerror/
|
|
110
109
|
*
|
|
111
110
|
* @param event - the error event
|
|
112
111
|
*/
|
|
@@ -114,13 +113,13 @@ export class WebSocket {
|
|
|
114
113
|
|
|
115
114
|
/**
|
|
116
115
|
* Sets an event handler which is invoked when a ping message is received.
|
|
117
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
116
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-onping/
|
|
118
117
|
*/
|
|
119
118
|
onping: () => void;
|
|
120
119
|
|
|
121
120
|
/**
|
|
122
121
|
* Sets an event handler which is invoked when a pong message is received.
|
|
123
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
122
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-onpong/
|
|
124
123
|
*/
|
|
125
124
|
onpong: () => void;
|
|
126
125
|
}
|
|
@@ -147,7 +146,7 @@ export class Blob {
|
|
|
147
146
|
|
|
148
147
|
/**
|
|
149
148
|
* k6 specific WebSocket parameters.
|
|
150
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-
|
|
149
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/params/
|
|
151
150
|
*/
|
|
152
151
|
export interface Params {
|
|
153
152
|
/** Request headers. */
|