@types/k6 0.53.2 → 0.54.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,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, 17 Sep 2024 08:09:49 GMT
11
+ * Last updated: Wed, 02 Oct 2024 08:39:47 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
k6/browser/index.d.ts CHANGED
@@ -163,6 +163,8 @@ export type ElementClickOptions = ElementHandlePointerOptions & {
163
163
  position?: { x: number; y: number };
164
164
  };
165
165
 
166
+ export type FrameCheckOptions = ElementClickOptions;
167
+
166
168
  export interface KeyboardModifierOptions {
167
169
  /**
168
170
  * `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the action.
@@ -391,19 +393,17 @@ export interface ScreenshotOptions {
391
393
  * - `mutation` - use a mutation observer
392
394
  * - `interval` - use a polling interval
393
395
  */
394
- export type PollingMethod = "raf" | "mutation" | "interval";
396
+ export type PollingMethod = number | "raf" | "mutation";
395
397
 
396
398
  export interface PollingOptions {
397
399
  /**
398
- * Polling method to use.
399
- * @default 'raf'
400
- */
401
- polling?: "raf" | "mutation" | "interval";
402
-
403
- /**
404
- * Polling interval in milliseconds if `polling` is set to `interval`.
400
+ * If `polling` is `'raf'`, then `pageFunction` is constantly executed in
401
+ * `requestAnimationFrame` callback. If the `polling` is `'mutation'` it
402
+ * will be called when a change is made to the DOM tree. If `polling` is
403
+ * a number, then it is treated as an interval in milliseconds at which
404
+ * the function would be executed. Defaults to `raf`.
405
405
  */
406
- interval?: number;
406
+ polling?: PollingMethod;
407
407
  }
408
408
 
409
409
  export interface ElementStateFilter {
@@ -1333,6 +1333,14 @@ export interface ElementHandle extends JSHandle {
1333
1333
  */
1334
1334
  selectText(options?: ElementHandleOptions): Promise<void>;
1335
1335
 
1336
+ /**
1337
+ * Checks or unchecks the input checkbox element.
1338
+ * @param checked Whether to check or uncheck the element.
1339
+ * @param options Options to customize the check action.
1340
+ * @returns A promise that resolves when the element is checked or unchecked.
1341
+ */
1342
+ setChecked(checked: boolean, options?: ElementClickOptions & StrictnessOptions): Promise<void>;
1343
+
1336
1344
  /**
1337
1345
  * Sets the file input element's value to the specified files.
1338
1346
  *
@@ -1578,6 +1586,15 @@ export interface Frame {
1578
1586
  */
1579
1587
  goto(url: string, options?: NavigationOptions): Promise<Response | null>;
1580
1588
 
1589
+ /**
1590
+ * Checks or unchecks the input checkbox element.
1591
+ * @param selector A selector to search for an element.
1592
+ * @param checked Whether to check or uncheck the element.
1593
+ * @param options Options to customize the check action.
1594
+ * @returns A promise that resolves when the element is checked or unchecked.
1595
+ */
1596
+ setChecked(selector: string, checked: boolean, options?: FrameCheckOptions & StrictnessOptions): Promise<void>;
1597
+
1581
1598
  /**
1582
1599
  * Replace the entire HTML document content.
1583
1600
  * @param html The HTML to use.
@@ -2029,6 +2046,14 @@ export interface Locator {
2029
2046
  options?: ElementHandleOptions,
2030
2047
  ): Promise<string[]>;
2031
2048
 
2049
+ /**
2050
+ * Checks or unchecks the input checkbox element.
2051
+ * @param checked Whether to check or uncheck the element.
2052
+ * @param options Options to customize the check action.
2053
+ * @returns A promise that resolves when the element is checked or unchecked.
2054
+ */
2055
+ setChecked(checked: boolean, options?: FrameCheckOptions): Promise<void>;
2056
+
2032
2057
  /**
2033
2058
  * Press a single key on the keyboard or a combination of keys.
2034
2059
  * A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
@@ -3066,6 +3091,15 @@ export interface Page {
3066
3091
  } & ScreenshotOptions,
3067
3092
  ): Promise<ArrayBuffer>;
3068
3093
 
3094
+ /**
3095
+ * Checks or unchecks the input checkbox element.
3096
+ * @param selector A selector to search for an element.
3097
+ * @param checked Whether to check or uncheck the element.
3098
+ * @param options Options to customize the check action.
3099
+ * @returns A promise that resolves when the element is checked or unchecked.
3100
+ */
3101
+ setChecked(selector: string, checked: boolean, options?: FrameCheckOptions & StrictnessOptions): Promise<void>;
3102
+
3069
3103
  /**
3070
3104
  * **NOTE** Use locator-based locator.selectOption(values[, options]) instead.
3071
3105
  *
@@ -3359,7 +3393,7 @@ export interface Page {
3359
3393
  * **Usage**
3360
3394
  *
3361
3395
  * ```js
3362
- * import { browser, networkProfiles } from 'k6/experimental/browser';
3396
+ * import { browser, networkProfiles } from 'k6/browser';
3363
3397
  * ... // redacted
3364
3398
  * const context = browser.newContext();
3365
3399
  * const page = context.newPage();
@@ -3516,11 +3550,12 @@ export interface Page {
3516
3550
  options?: {
3517
3551
  /**
3518
3552
  * If `polling` is `'raf'`, then `pageFunction` is constantly executed in
3519
- * `requestAnimationFrame` callback. If `polling` is a number, then it is
3520
- * treated as an interval in milliseconds at which the function would be
3521
- * executed. Defaults to `raf`.
3553
+ * `requestAnimationFrame` callback. If the `polling` is `'mutation'` it
3554
+ * will be called when a change is made to the DOM tree. If `polling` is
3555
+ * a number, then it is treated as an interval in milliseconds at which
3556
+ * the function would be executed. Defaults to `raf`.
3522
3557
  */
3523
- polling?: number | "raf";
3558
+ polling?: PollingMethod;
3524
3559
 
3525
3560
  /**
3526
3561
  * Maximum time in milliseconds. Defaults to `30` seconds. Default is
@@ -4192,7 +4192,7 @@ export interface Page {
4192
4192
  * **Usage**
4193
4193
  *
4194
4194
  * ```js
4195
- * import { browser, networkProfiles } from 'k6/experimental/browser';
4195
+ * import { browser, networkProfiles } from 'k6/browser';
4196
4196
  * ... // redacted
4197
4197
  * const context = browser.newContext();
4198
4198
  * const page = context.newPage();
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The `k6-experimental/csv` module provides efficient ways to handle CSV files in k6, offering faster parsing and lower memory
3
+ * usage compared to traditional JavaScript-based libraries.
4
+ *
5
+ * This module includes functionalities for both full-file parsing and streaming, allowing users to choose between
6
+ * performance and memory optimization.
7
+ */
8
+
9
+ import type { SharedArray } from "k6/data";
10
+ import * as fs from "k6/experimental/fs";
11
+
12
+ /**
13
+ * The parse function parses an entire CSV file at once and returns a promise
14
+ * that resolves to a `SharedArray` instance.
15
+ *
16
+ * This function uses Go-based processing, which results in faster parsing and
17
+ * lower memory usage compared to JavaScript alternatives.
18
+ *
19
+ * It's ideal for scenarios where performance is a priority, and the entire CSV
20
+ * file can be loaded into memory.
21
+ *
22
+ * @param {fs.File} file - The file path as a `fs.File` instance. Relative paths are resolved relative to the k6 script.
23
+ * @param {Partial<Options>} [options] - An optional configuration object for the parsing operation.
24
+ */
25
+ export function parse(file: fs.File, options?: Partial<Options>): Promise<typeof SharedArray>;
26
+
27
+ /**
28
+ * The `csv.Parser` class provides a streaming parser that reads CSV files
29
+ * line-by-line, offering fine-grained control over the parsing process and
30
+ * minimizing memory consumption.
31
+ *
32
+ * It's well-suited for scenarios where memory efficiency is crucial or when
33
+ * you need to process large CSV files without loading the entire file into memory.
34
+ */
35
+ export class Parser {
36
+ /**
37
+ * Constructs a new Parser instance.
38
+ *
39
+ * @param {fs.File} file - A csv file to parse, provided as a `fs.File` instance.
40
+ * @param {Partial<Options>} [options] - An optional configuration object for the parser.
41
+ */
42
+ constructor(file: fs.File, options?: Partial<Options>);
43
+
44
+ /**
45
+ * Parses the next record from the CSV file.
46
+ *
47
+ * @returns {Promise<{done: boolean, value: string[]}>} - A promise that
48
+ * resolves to an object with the `done` property set to `true` if the end of the file
49
+ * is reached, and the `value` property set to an array of strings representing the record.
50
+ */
51
+ next(): Promise<{ done: boolean; value: string[] }>;
52
+ }
53
+
54
+ /**
55
+ * The Options object describes the configuration available for the operation of parsing CSV
56
+ * files using the `parse` function and the `Parser` class.
57
+ */
58
+ export interface Options {
59
+ /**
60
+ * The delimiter character used in the CSV file. Default is ','.
61
+ */
62
+ delimiter: string;
63
+
64
+ /**
65
+ * Whether to skip the first line of the CSV file. Default is false.
66
+ */
67
+ skipFirstLine: boolean;
68
+
69
+ /**
70
+ * The line number the parsing should start from. Default is 0.
71
+ */
72
+ fromLine: number;
73
+
74
+ /**
75
+ * The line number the parsing should stop at. Default is undefined.
76
+ */
77
+ toLine?: number;
78
+ }
79
+
80
+ export * as default from "k6/experimental/csv";
@@ -37,8 +37,9 @@ export class WebSocket {
37
37
 
38
38
  /**
39
39
  * The type of binary data being transmitted over the connection.
40
+ * @default "blob"
40
41
  */
41
- readonly binaryType: BinaryType;
42
+ binaryType: BinaryType;
42
43
 
43
44
  /**
44
45
  * The Websocket constructor returns a newly created WebSocket object.
@@ -56,7 +57,7 @@ export class WebSocket {
56
57
  *
57
58
  * @param data - the data to send to the server
58
59
  */
59
- send(data: string | ArrayBuffer | Blob): void;
60
+ send(data: string | ArrayBuffer | Blob | ArrayBufferView): void;
60
61
 
61
62
  /**
62
63
  * Bind event names to event handlers to be executed when their
k6/net/grpc/index.d.ts CHANGED
@@ -78,15 +78,24 @@ export interface TLSParams {
78
78
 
79
79
  export interface Params {
80
80
  /**
81
- * @deprecated Use metadata instead.
81
+ * Object with key-value pairs representing custom metadata the user would like to add to the request.
82
82
  */
83
- headers?: object;
84
-
85
83
  metadata?: object;
86
84
 
85
+ /**
86
+ * Key-value pairs where the keys are names of tags and the values are tag values
87
+ */
87
88
  tags?: object;
88
89
 
90
+ /**
91
+ * Request timeout to use.
92
+ */
89
93
  timeout?: string | number;
94
+
95
+ /**
96
+ * Specify if response messages should be discarded.
97
+ */
98
+ discardResponseMessage?: boolean;
90
99
  }
91
100
 
92
101
  export interface GrpcError {
@@ -141,6 +150,16 @@ export type StreamEvent =
141
150
  */
142
151
  | "end";
143
152
 
153
+ /**
154
+ * StreamMessageMetadata handles gRPC stream messages's metadata
155
+ */
156
+ export interface StreamMessageMetadata {
157
+ /**
158
+ * Contains the timestamp of the original event (for example, when a message has been received).
159
+ */
160
+ ts: number;
161
+ }
162
+
144
163
  /**
145
164
  * Stream allows you to use streaming RPCs.
146
165
  */
@@ -160,7 +179,10 @@ export class Stream {
160
179
  * @param event - the event to listen for
161
180
  * @param listener - the callback to invoke when the event is emitted
162
181
  */
163
- on(event: StreamEvent, listener: (data: object | GrpcError | undefined) => void): void;
182
+ on(
183
+ event: StreamEvent,
184
+ listener: (data: object | GrpcError | undefined, metadata: StreamMessageMetadata) => void,
185
+ ): void;
164
186
 
165
187
  /**
166
188
  * Writes a request to the stream.
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.53.2",
3
+ "version": "0.54.1",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -61,6 +61,6 @@
61
61
  },
62
62
  "scripts": {},
63
63
  "dependencies": {},
64
- "typesPublisherContentHash": "157d18815426920cc271f8668e306138a0c10336ba1266c5cacd6af2b8bff05b",
64
+ "typesPublisherContentHash": "16df1d4804829cafe4d54bc250f82dc44d94a5df3a0b67262eaf6ffa33f024c7",
65
65
  "typeScriptVersion": "4.8"
66
66
  }
@@ -1,47 +0,0 @@
1
- /**
2
- * This module provides setInterval, setTimeout and co.
3
- */
4
-
5
- /**
6
- * Set a timer that executes a function once the timer expires.
7
- *
8
- * @param functionRef - The function to be executed.
9
- * @param delay - The delay in milliseconds.
10
- * @param args - The arguments to be passed to the function.
11
- * @returns The timer id.
12
- */
13
- export function setTimeout(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutID;
14
-
15
- /**
16
- * Cancels a timer previously set with setTimeout().
17
- *
18
- * @param timeoutID - The timer id to be cancelled.
19
- */
20
- export function clearTimeout(timeoutID: TimeoutID): void;
21
-
22
- /**
23
- * Repeatedly execute a function, with a fixed time delay between each call.
24
- *
25
- * @param functionRef - The function to be executed.
26
- * @param delay - The delay in milliseconds.
27
- * @param args - The arguments to be passed to the function.
28
- * @returns The interval id.
29
- */
30
- export function setInterval(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): IntervalID;
31
-
32
- /**
33
- * Cancels an interval previously set with setInterval().
34
- *
35
- * @param intervalID - The interval id to be cancelled.
36
- */
37
- export function clearInterval(intervalID: IntervalID): void;
38
-
39
- /**
40
- * Type alias for a timer id.
41
- */
42
- export type TimeoutID = number;
43
-
44
- /**
45
- * Type alias for a interval id.
46
- */
47
- export type IntervalID = number;