@types/k6 0.53.2 → 0.54.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 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: Mon, 30 Sep 2024 10:08: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.
@@ -1333,6 +1335,14 @@ export interface ElementHandle extends JSHandle {
1333
1335
  */
1334
1336
  selectText(options?: ElementHandleOptions): Promise<void>;
1335
1337
 
1338
+ /**
1339
+ * Checks or unchecks the input checkbox element.
1340
+ * @param checked Whether to check or uncheck the element.
1341
+ * @param options Options to customize the check action.
1342
+ * @returns A promise that resolves when the element is checked or unchecked.
1343
+ */
1344
+ setChecked(checked: boolean, options?: ElementClickOptions & StrictnessOptions): Promise<void>;
1345
+
1336
1346
  /**
1337
1347
  * Sets the file input element's value to the specified files.
1338
1348
  *
@@ -1578,6 +1588,15 @@ export interface Frame {
1578
1588
  */
1579
1589
  goto(url: string, options?: NavigationOptions): Promise<Response | null>;
1580
1590
 
1591
+ /**
1592
+ * Checks or unchecks the input checkbox element.
1593
+ * @param selector A selector to search for an element.
1594
+ * @param checked Whether to check or uncheck the element.
1595
+ * @param options Options to customize the check action.
1596
+ * @returns A promise that resolves when the element is checked or unchecked.
1597
+ */
1598
+ setChecked(selector: string, checked: boolean, options?: FrameCheckOptions & StrictnessOptions): Promise<void>;
1599
+
1581
1600
  /**
1582
1601
  * Replace the entire HTML document content.
1583
1602
  * @param html The HTML to use.
@@ -2029,6 +2048,14 @@ export interface Locator {
2029
2048
  options?: ElementHandleOptions,
2030
2049
  ): Promise<string[]>;
2031
2050
 
2051
+ /**
2052
+ * Checks or unchecks the input checkbox element.
2053
+ * @param checked Whether to check or uncheck the element.
2054
+ * @param options Options to customize the check action.
2055
+ * @returns A promise that resolves when the element is checked or unchecked.
2056
+ */
2057
+ setChecked(checked: boolean, options?: FrameCheckOptions): Promise<void>;
2058
+
2032
2059
  /**
2033
2060
  * Press a single key on the keyboard or a combination of keys.
2034
2061
  * 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 +3093,15 @@ export interface Page {
3066
3093
  } & ScreenshotOptions,
3067
3094
  ): Promise<ArrayBuffer>;
3068
3095
 
3096
+ /**
3097
+ * Checks or unchecks the input checkbox element.
3098
+ * @param selector A selector to search for an element.
3099
+ * @param checked Whether to check or uncheck the element.
3100
+ * @param options Options to customize the check action.
3101
+ * @returns A promise that resolves when the element is checked or unchecked.
3102
+ */
3103
+ setChecked(selector: string, checked: boolean, options?: FrameCheckOptions & StrictnessOptions): Promise<void>;
3104
+
3069
3105
  /**
3070
3106
  * **NOTE** Use locator-based locator.selectOption(values[, options]) instead.
3071
3107
  *
@@ -3359,7 +3395,7 @@ export interface Page {
3359
3395
  * **Usage**
3360
3396
  *
3361
3397
  * ```js
3362
- * import { browser, networkProfiles } from 'k6/experimental/browser';
3398
+ * import { browser, networkProfiles } from 'k6/browser';
3363
3399
  * ... // redacted
3364
3400
  * const context = browser.newContext();
3365
3401
  * const page = context.newPage();
@@ -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.0",
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": "117f96c1bd174240bb9f518388a69fc69bbb14dd874730e2db3ea53c0513b9c6",
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;