@types/k6 2.0.1 → 2.2.1

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 CHANGED
@@ -8,8 +8,8 @@ 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: Thu, 16 Jul 2026 14:38:45 GMT
11
+ * Last updated: Mon, 14 Sep 2026 18:38:28 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
15
- These definitions were written by [Mihail Stoykov](https://github.com/MStoykov), [Ivan](https://github.com/codebien), [Théo Crevon](https://github.com/oleiade), [Ankur Agarwal](https://github.com/ankur22), [İnanç Gümüş](https://github.com/inancgumus), [Joan López de la Franca Beltran](https://github.com/joanlopez), [Agnès Toulet](https://github.com/AgnesToulet), and [Iván Szkiba](https://github.com/szkiba).
15
+ These definitions were written by [Mihail Stoykov](https://github.com/MStoykov), [Ivan](https://github.com/codebien), [Théo Crevon](https://github.com/oleiade), [Ankur Agarwal](https://github.com/ankur22), [İnanç Gümüş](https://github.com/inancgumus), [Joan López de la Franca Beltran](https://github.com/joanlopez), [Agnès Toulet](https://github.com/AgnesToulet), [Iván Szkiba](https://github.com/szkiba), and [Jan Hildebrandt](https://github.com/janHildebrandt98).
k6/browser/index.d.ts CHANGED
@@ -728,6 +728,66 @@ export interface NewBrowserContextOptions {
728
728
  */
729
729
  export const browser: Browser;
730
730
 
731
+ /**
732
+ * The `chromium` named export allows attaching to an already running
733
+ * Chromium-based browser over the Chrome DevTools Protocol (CDP), instead of
734
+ * relying on the browser instance that k6 launches and manages for you.
735
+ */
736
+ export const chromium: BrowserType;
737
+
738
+ /**
739
+ * `BrowserType` is the entry point to connect to an existing Chromium-based
740
+ * browser.
741
+ */
742
+ export interface BrowserType {
743
+ /**
744
+ * Attaches to an already running Chromium-based browser over the Chrome
745
+ * DevTools Protocol (CDP), and returns the corresponding `Browser`
746
+ * instance.
747
+ *
748
+ * The returned `Browser` is closed automatically at the end of the
749
+ * iteration. Use {@link ConnectedBrowser.close | close} to release the
750
+ * connection earlier.
751
+ *
752
+ * **Usage**
753
+ *
754
+ * ```js
755
+ * const browser = await chromium.connectOverCDP('ws://localhost:9222/devtools/browser/<id>');
756
+ * const page = await browser.newPage();
757
+ *
758
+ * try {
759
+ * await page.goto('https://quickpizza.grafana.com/');
760
+ * } finally {
761
+ * await page.close();
762
+ * await browser.close();
763
+ * }
764
+ * ```
765
+ *
766
+ * @param wsEndpoint The WebSocket endpoint of the browser to attach to,
767
+ * e.g. 'ws://localhost:9222/devtools/browser/<id>'.
768
+ */
769
+ connectOverCDP(wsEndpoint: string): Promise<ConnectedBrowser>;
770
+ }
771
+
772
+ /**
773
+ * `ConnectedBrowser` represents a web browser instance that k6 attached to over
774
+ * the Chrome DevTools Protocol (CDP), rather than launched itself.
775
+ *
776
+ * On top of the `Browser` API, it exposes a `close` method, since the
777
+ * connection is user managed and can be released on demand.
778
+ */
779
+ export interface ConnectedBrowser extends Browser {
780
+ /**
781
+ * Closes the connection to the browser, and all of its `BrowserContext`s
782
+ * and `Page`s.
783
+ *
784
+ * Calling this method is optional: the connection is closed automatically
785
+ * at the end of the iteration. Closing an already closed `Browser` is a
786
+ * no-op.
787
+ */
788
+ close(): Promise<void>;
789
+ }
790
+
731
791
  /**
732
792
  * `Browser` represents the main web browser instance.
733
793
  */
k6/options/index.d.ts CHANGED
@@ -50,6 +50,9 @@ export interface Options {
50
50
  /** Cloud options */
51
51
  cloud?: CloudOptions;
52
52
 
53
+ /** handleSummary() function timeout. */
54
+ handleSummaryTimeout?: string;
55
+
53
56
  /** Static hostname mapping. */
54
57
  hosts?: { [name: string]: string };
55
58
 
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "2.0.1",
3
+ "version": "2.2.1",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -44,6 +44,11 @@
44
44
  "name": "Iván Szkiba",
45
45
  "githubUsername": "szkiba",
46
46
  "url": "https://github.com/szkiba"
47
+ },
48
+ {
49
+ "name": "Jan Hildebrandt",
50
+ "githubUsername": "janHildebrandt98",
51
+ "url": "https://github.com/janHildebrandt98"
47
52
  }
48
53
  ],
49
54
  "type": "module",
@@ -78,6 +83,6 @@
78
83
  "scripts": {},
79
84
  "dependencies": {},
80
85
  "peerDependencies": {},
81
- "typesPublisherContentHash": "d9c24a7dfc71069cc554e117bf8e7dc28fd1d8fb715409286ee76f18b80f32fb",
86
+ "typesPublisherContentHash": "66510a73d3d6dfacdb611e96c35dafe7e049daf394b182f7b15c361be3dacc95",
82
87
  "typeScriptVersion": "5.6"
83
88
  }
k6/websockets/index.d.ts CHANGED
@@ -122,6 +122,16 @@ export class WebSocket {
122
122
  * https://grafana.com/docs/k6/latest/javascript-api/k6-websockets/websocket/websocket-onpong/
123
123
  */
124
124
  onpong: () => void;
125
+
126
+ static readonly CONNECTING: 0;
127
+ static readonly OPEN: 1;
128
+ static readonly CLOSING: 2;
129
+ static readonly CLOSED: 3;
130
+
131
+ readonly CONNECTING: 0;
132
+ readonly OPEN: 1;
133
+ readonly CLOSING: 2;
134
+ readonly CLOSED: 3;
125
135
  }
126
136
 
127
137
  export type BlobPart = ArrayBuffer | ArrayBufferView | Blob | string;
@@ -171,72 +181,19 @@ export interface Params {
171
181
  /**
172
182
  * ReadyState describes the possible states of a WebSocket connection.
173
183
  */
174
- export enum ReadyState {
175
- /**
176
- * Socket has been created. The connection is not yet open.
177
- */
178
- Connecting = 0,
179
-
180
- /**
181
- * The connection is open and ready to communicate.
182
- */
183
- Open = 1,
184
-
185
- /**
186
- * The connection is in the process of closing.
187
- */
188
- Closing = 2,
189
-
190
- /**
191
- * The connection is closed or couldn't be opened.
192
- */
193
- Closed = 3,
194
- }
184
+ export type ReadyState = 0 | 1 | 2 | 3;
195
185
 
196
186
  /**
197
187
  * BinaryType describes the possible types of binary data that can be
198
188
  * transmitted over a Websocket connection.
199
189
  */
200
- export enum BinaryType {
201
- Blob = "blob",
202
- ArrayBuffer = "arraybuffer",
203
- }
190
+ export type BinaryType = "blob" | "arraybuffer";
204
191
 
205
192
  /**
206
193
  * EventName describes the possible events that can be emitted
207
194
  * by a Websocket connection.
208
195
  */
209
- export enum EventName {
210
- /**
211
- * Event fired when the connection is opened and ready to communicate.
212
- */
213
- Open = "open",
214
-
215
- /**
216
- * Event fired when the connection has been closed.
217
- */
218
- Close = "close",
219
-
220
- /**
221
- * Event fired when a connection has been closed due to an error.
222
- */
223
- Error = "error",
224
-
225
- /**
226
- * Event fired when a message has been received from the server.
227
- */
228
- Message = "message",
229
-
230
- /**
231
- * Event fired when a ping message has been received from the server.
232
- */
233
- Ping = "ping",
234
-
235
- /**
236
- * Event fired when a pong message has been received from the server.
237
- */
238
- Pong = "pong",
239
- }
196
+ export type EventName = "open" | "close" | "error" | "message" | "ping" | "pong";
240
197
 
241
198
  /**
242
199
  * MessageEvent is a simple interface that holds the data of a message received from the server.
@@ -250,7 +207,7 @@ export interface MessageEvent {
250
207
  /**
251
208
  * the type of the event.
252
209
  */
253
- type: MessageType;
210
+ type: EventName;
254
211
 
255
212
  /**
256
213
  * The read-only property that returns the time (in milliseconds) at which the event was created.
@@ -258,40 +215,6 @@ export interface MessageEvent {
258
215
  timestamp: number;
259
216
  }
260
217
 
261
- /**
262
- * WebSocket message types, as defined in RFC 6455, section 11.8.
263
- */
264
- export enum MessageType {
265
- /**
266
- * The message is a text message. The text message payload is
267
- * interpreted as UTF-8 encodedtext data.
268
- */
269
- Text = 1,
270
-
271
- /**
272
- * The message is a binary message.
273
- */
274
- Binary = 2,
275
-
276
- /**
277
- * The message is a close control message. The optional message
278
- * payload contains a numeric code and a text reason.
279
- */
280
- Close = 8,
281
-
282
- /**
283
- * The message is a ping control message. The optional message
284
- * payload is UTF-8 encoded text.
285
- */
286
- PingMessage = 9,
287
-
288
- /**
289
- * The message is a pong control message. The optional message
290
- * payload is UTF-8 encoded text.
291
- */
292
- PongMessage = 10,
293
- }
294
-
295
218
  /**
296
219
  * ErrorEvent is a simple interface that holds the data of an error event.
297
220
  */
@@ -299,7 +222,7 @@ export interface ErrorEvent {
299
222
  /**
300
223
  * the type of the event.
301
224
  */
302
- type: MessageType;
225
+ type: EventName;
303
226
 
304
227
  /**
305
228
  * The read-only property that returns the error message.
@@ -315,10 +238,4 @@ export interface ErrorEvent {
315
238
  /**
316
239
  * CompressionAlgorithm describes the possible compression algorithms.
317
240
  */
318
- export enum CompressionAlgorithm {
319
- /**
320
- * Deflate compression algorithm.
321
- * k6 supports only this compression algorithm.
322
- */
323
- Deflate = "deflate",
324
- }
241
+ export type CompressionAlgorithm = "deflate";