@types/k6 0.49.3 → 0.50.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, 19 Mar 2024 08:35:31 GMT
11
+ * Last updated: Tue, 23 Apr 2024 12:10:41 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -115,6 +115,23 @@ export interface EventSequenceOptions {
115
115
  delay?: number;
116
116
  }
117
117
 
118
+ export interface File {
119
+ /**
120
+ * File name
121
+ */
122
+ name: string;
123
+
124
+ /**
125
+ * File type
126
+ */
127
+ mimeType: string;
128
+
129
+ /**
130
+ * File content
131
+ */
132
+ buffer: ArrayBuffer;
133
+ }
134
+
118
135
  export type ElementHandleOptions = {
119
136
  /**
120
137
  * Setting this to `true` will bypass the actionability checks (visible,
@@ -626,6 +643,11 @@ export interface Browser {
626
643
  options?: NewBrowserContextOptions,
627
644
  ): Page;
628
645
 
646
+ /**
647
+ * Returns the browser application's user agent.
648
+ */
649
+ userAgent(): string;
650
+
629
651
  /**
630
652
  * Returns the browser application's version.
631
653
  */
@@ -637,6 +659,33 @@ export interface Browser {
637
659
  * separate pages, cache, and cookies.
638
660
  */
639
661
  export interface BrowserContext {
662
+ /**
663
+ * Adds a script which will be evaluated in one of the following scenarios:
664
+ * - Whenever a page is created in the browser context or is navigated.
665
+ * - Whenever a child frame is attached or navigated in any page in the
666
+ * browser context. In this case, the script is evaluated in the context
667
+ * of the newly attached frame.
668
+ *
669
+ * The script is evaluated after the document is created but before any of
670
+ * its scripts were run. This is useful to amend the JavaScript environment,
671
+ * e.g. to override `Math.random`.
672
+ *
673
+ * **Usage**
674
+ *
675
+ * An example of overriding `Math.random` before the page loads:
676
+ *
677
+ * ```js
678
+ * const browserContext = browser.newContext();
679
+ * browserContext.addInitScript("Math.random = function(){return 0}");
680
+ *
681
+ * const page = browserContext.newPage();
682
+ * await page.goto(url);
683
+ * ```
684
+ *
685
+ * @param script Script to be evaluated in all pages in the browser context.
686
+ */
687
+ addInitScript(script: string | { content?: string }): void;
688
+
640
689
  /**
641
690
  * Returns the `Browser` instance that this `BrowserContext` belongs to.
642
691
  */
@@ -1001,12 +1050,163 @@ export interface ElementHandle extends JSHandle {
1001
1050
  */
1002
1051
  boundingBox(): Rect;
1003
1052
 
1053
+ /**
1054
+ * Checks the checkbox element.
1055
+ * @param options The options to use.
1056
+ */
1057
+ check(options?: ElementClickOptions & StrictnessOptions): void;
1058
+
1059
+ /**
1060
+ * Clicks the element.
1061
+ * @param options The options to use.
1062
+ * @returns A promise that resolves when the element is clicked.
1063
+ */
1064
+ click(
1065
+ options?: {
1066
+ /**
1067
+ * The mouse button (`left`, `middle` or `right`) to use during the action.
1068
+ * Defaults to `left`.
1069
+ */
1070
+ button?: MouseButton;
1071
+
1072
+ /**
1073
+ * The number of times the action is performed. Defaults to `1`.
1074
+ */
1075
+ clickCount?: number;
1076
+
1077
+ /**
1078
+ * Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
1079
+ */
1080
+ delay?: number;
1081
+
1082
+ /**
1083
+ * Setting this to `true` will bypass the actionability checks (`visible`,
1084
+ * `stable`, `enabled`). Defaults to `false`.
1085
+ */
1086
+ force?: boolean;
1087
+
1088
+ /**
1089
+ * `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
1090
+ * action. If not specified, currently pressed modifiers are used,
1091
+ * otherwise defaults to `null`.
1092
+ */
1093
+ modifiers?: KeyboardModifier[];
1094
+
1095
+ /**
1096
+ * If set to `true` and a navigation occurs from performing this action, it
1097
+ * will not wait for it to complete. Defaults to `false`.
1098
+ */
1099
+ noWaitAfter?: boolean;
1100
+
1101
+ /**
1102
+ * A point to use relative to the top left corner of the element. If not
1103
+ * supplied, a visible point of the element is used.
1104
+ */
1105
+ position?: {
1106
+ x: number;
1107
+
1108
+ y: number;
1109
+ };
1110
+
1111
+ /**
1112
+ * Maximum time in milliseconds. Defaults to `30` seconds. Default is
1113
+ * overridden by the `setDefaultTimeout` option on `BrowserContext` or
1114
+ * `page` methods.
1115
+ *
1116
+ * Setting the value to `0` will disable the timeout.
1117
+ */
1118
+ timeout?: number;
1119
+
1120
+ /**
1121
+ * Setting this to `true` will perform the actionability checks without
1122
+ * performing the action. Useful to wait until the element is ready for the
1123
+ * action without performing it. Defaults to `false`.
1124
+ */
1125
+ trial?: boolean;
1126
+ },
1127
+ ): Promise<void>;
1128
+
1004
1129
  /**
1005
1130
  * Get the content frame for element handles.
1006
1131
  * @returns The content frame handle of the element handle.
1007
1132
  */
1008
1133
  contentFrame(): Frame;
1009
1134
 
1135
+ /**
1136
+ * Double clicks the element.
1137
+ * @param options The options to use.
1138
+ */
1139
+ dblclick(
1140
+ options?: {
1141
+ /**
1142
+ * The mouse button (`left`, `middle` or `right`) to use during the action.
1143
+ * Defaults to `left`.
1144
+ */
1145
+ button?: MouseButton;
1146
+
1147
+ /**
1148
+ * Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
1149
+ */
1150
+ delay?: number;
1151
+
1152
+ /**
1153
+ * Setting this to `true` will bypass the actionability checks (`visible`,
1154
+ * `stable`, `enabled`). Defaults to `false`.
1155
+ */
1156
+ force?: boolean;
1157
+
1158
+ /**
1159
+ * `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
1160
+ * action. If not specified, currently pressed modifiers are used,
1161
+ * otherwise defaults to `null`.
1162
+ */
1163
+ modifiers?: KeyboardModifier[];
1164
+
1165
+ /**
1166
+ * If set to `true` and a navigation occurs from performing this action, it
1167
+ * will not wait for it to complete. Defaults to `false`.
1168
+ */
1169
+ noWaitAfter?: boolean;
1170
+
1171
+ /**
1172
+ * A point to use relative to the top left corner of the element. If not
1173
+ * supplied, a visible point of the element is used.
1174
+ */
1175
+ position?: {
1176
+ x: number;
1177
+
1178
+ y: number;
1179
+ };
1180
+
1181
+ /**
1182
+ * Maximum time in milliseconds. Defaults to `30` seconds. Default is
1183
+ * overridden by the `setDefaultTimeout` option on `BrowserContext` or
1184
+ * `page` methods.
1185
+ *
1186
+ * Setting the value to `0` will disable the timeout.
1187
+ */
1188
+ timeout?: number;
1189
+
1190
+ /**
1191
+ * Setting this to `true` will perform the actionability checks without
1192
+ * performing the action. Useful to wait until the element is ready for the
1193
+ * action without performing it. Defaults to `false`.
1194
+ */
1195
+ trial?: boolean;
1196
+ },
1197
+ ): void;
1198
+
1199
+ /**
1200
+ * Dispatches a DOM event to the element.
1201
+ * @param type DOM event type: `"click"` etc.
1202
+ * @param eventInit Optional event-specific initialization properties.
1203
+ * @param options
1204
+ */
1205
+ dispatchEvent(
1206
+ type: string,
1207
+ eventInit?: EvaluationArgument,
1208
+ ): void;
1209
+
1010
1210
  /**
1011
1211
  * Fill the `input` or `textarea` element with the provided `value`.
1012
1212
  * @param value Value to fill for the `input` or `textarea` element.
@@ -1131,6 +1331,33 @@ export interface ElementHandle extends JSHandle {
1131
1331
  */
1132
1332
  selectText(options?: ElementHandleOptions): void;
1133
1333
 
1334
+ /**
1335
+ * Sets the file input element's value to the specified files.
1336
+ *
1337
+ * To work with local files on the file system, use the experimental
1338
+ * fs module to load and read the file contents.
1339
+ *
1340
+ * The {@link ElementHandle | element handle} must be an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
1341
+ * @param files
1342
+ * @param options
1343
+ */
1344
+ setInputFiles(files: File | File[], options?: {
1345
+ /**
1346
+ * Maximum time in milliseconds. Pass 0 to disable the timeout. Default
1347
+ * is overridden by the setDefaultTimeout option on {@link BrowserContext} or
1348
+ * {@link Page}.
1349
+ * @default 30000
1350
+ */
1351
+ timeout?: number;
1352
+
1353
+ /**
1354
+ * If set to `true` and a navigation occurs from performing this action, it
1355
+ * does not wait for it to complete.
1356
+ * @default false
1357
+ */
1358
+ noWaitAfter?: boolean;
1359
+ }): void;
1360
+
1134
1361
  /**
1135
1362
  * Scrolls element into view if needed, and then uses `page.tapscreen` to tap in the center of the element
1136
1363
  * or at the specified position.
@@ -1482,6 +1709,36 @@ export interface Frame {
1482
1709
  */
1483
1710
  isVisible(selector: string, options?: StrictnessOptions): boolean;
1484
1711
 
1712
+ /**
1713
+ * Sets the file input element's value to the specified files.
1714
+ *
1715
+ * To work with local files on the file system, use the experimental
1716
+ * fs module to load and read the file contents.
1717
+ *
1718
+ * This method expects a `selector` to point to an
1719
+ * [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
1720
+ * @param selector A selector to search for an element. If there are multiple
1721
+ * elements satisfying the selector, the first will be used.
1722
+ * @param files
1723
+ * @param options
1724
+ */
1725
+ setInputFiles(selector: string, files: File | File[], options?: {
1726
+ /**
1727
+ * Maximum time in milliseconds. Pass 0 to disable the timeout. Default
1728
+ * is overridden by the setDefaultTimeout option on {@link BrowserContext} or
1729
+ * {@link Page}
1730
+ * @default 30000
1731
+ */
1732
+ timeout?: number;
1733
+
1734
+ /**
1735
+ * If set to `true` and a navigation occurs from performing this action, it
1736
+ * will not wait for it to complete.
1737
+ * @default false
1738
+ */
1739
+ noWaitAfter?: boolean;
1740
+ }): void;
1741
+
1485
1742
  /**
1486
1743
  * Wait for the given function to return a truthy value.
1487
1744
  * @param predicate The function to call and wait for.
@@ -1559,7 +1816,7 @@ export interface JSHandle<T = any> {
1559
1816
  evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): JSHandle<R>;
1560
1817
 
1561
1818
  /**
1562
- * Fethes a map with own property names of of the `JSHandle` with their values as
1819
+ * Fetches a map with own property names of of the `JSHandle` with their values as
1563
1820
  * `JSHandle` instances.
1564
1821
  * @returns A map with property names as keys and `JSHandle` instances for the property values.
1565
1822
  */
@@ -2917,6 +3174,36 @@ export interface Page {
2917
3174
  */
2918
3175
  setExtraHTTPHeaders(headers: { [key: string]: string }): void;
2919
3176
 
3177
+ /**
3178
+ * Sets the file input element's value to the specified files.
3179
+ *
3180
+ * To work with local files on the file system, use the experimental
3181
+ * fs module to load and read the file contents.
3182
+ *
3183
+ * This method expects a `selector` to point to an
3184
+ * [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
3185
+ * @param selector A selector to search for an element. If there are multiple
3186
+ * elements satisfying the selector, the first will be used.
3187
+ * @param files
3188
+ * @param options
3189
+ */
3190
+ setInputFiles(selector: string, files: File | File[], options?: {
3191
+ /**
3192
+ * Maximum time in milliseconds. Pass 0 to disable the timeout. Default
3193
+ * is overridden by the setDefaultTimeout option on {@link BrowserContext} or
3194
+ * {@link Page}
3195
+ * @default 30000
3196
+ */
3197
+ timeout?: number;
3198
+
3199
+ /**
3200
+ * If set to `true` and a navigation occurs from performing this action, it
3201
+ * will not wait for it to complete.
3202
+ * @default false
3203
+ */
3204
+ noWaitAfter?: boolean;
3205
+ }): void;
3206
+
2920
3207
  /**
2921
3208
  * This will update the page's width and height.
2922
3209
  *
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  /**
6
- * Set a timer which execution a function once the timer expires.
6
+ * Set a timer that executes a function once the timer expires.
7
7
  *
8
8
  * @param functionRef - The function to be executed.
9
9
  * @param delay - The delay in milliseconds.
@@ -13,7 +13,7 @@
13
13
  export function setTimeout(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutID;
14
14
 
15
15
  /**
16
- * Cancels a timeout previously set with setTimeout().
16
+ * Cancels a timer previously set with setTimeout().
17
17
  *
18
18
  * @param timeoutID - The timer id to be cancelled.
19
19
  */
@@ -30,7 +30,7 @@ export function clearTimeout(timeoutID: TimeoutID): void;
30
30
  export function setInterval(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): IntervalID;
31
31
 
32
32
  /**
33
- * Cancels a interval previously set with setInterval().
33
+ * Cancels an interval previously set with setInterval().
34
34
  *
35
35
  * @param intervalID - The interval id to be cancelled.
36
36
  */
@@ -91,14 +91,14 @@ export interface SubtleCrypto {
91
91
  *
92
92
  * To export a key, the key must have `CryptoKey.extractable` set to `true`.
93
93
  *
94
- * @param format the format in which to export the key. Currently, only "raw" is supported.
94
+ * @param format the format in which to export the key. Currently, only "raw" and "jwk" are supported.
95
95
  * @param key the key to export.
96
96
  * @throws {InvalidAccessError} - if the key is not extractable.
97
97
  * @throws {NotSupportedError} - if the format is not supported.
98
98
  * @throws {TypeError} - when trying to use an invalid format.
99
99
  * @returns A promise that resolves with the exported key.
100
100
  */
101
- exportKey(format: "raw", key: CryptoKey): Promise<ArrayBuffer>;
101
+ exportKey(format: "raw" | "jwk", key: CryptoKey): Promise<ArrayBuffer | JWK>;
102
102
 
103
103
  /**
104
104
  * Use the `generateKey()` method to generate a new key (for symmetric
@@ -121,7 +121,7 @@ export interface SubtleCrypto {
121
121
  * It takes as input a key in an external, portable format and gives you
122
122
  * a `CryptoKey` object that can be used in the Web Crypto API.
123
123
  *
124
- * @param format the format of the key to import. Currently, only "raw" is supported.
124
+ * @param format the format of the key to import. Currently, only "raw" and "jwk" are supported.
125
125
  * @param keyData the key data to import.
126
126
  * @param algorithm defines the algorithm to use and any extra-parameters.
127
127
  * @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
@@ -131,8 +131,8 @@ export interface SubtleCrypto {
131
131
  * @returns A promise that resolves with the imported `CryptoKey`.
132
132
  */
133
133
  importKey(
134
- format: "raw",
135
- keyData: ArrayBuffer | ArrayBufferView | DataView,
134
+ format: "raw" | "jwk",
135
+ keyData: ArrayBuffer | ArrayBufferView | DataView | JWK,
136
136
  algorithm: "AES-CBC" | "AES-CTR" | "AES-GCM" | Algorithm<"AES-CBC" | "AES-CTR" | "AES-GCM"> | HmacImportParams,
137
137
  extractable: boolean,
138
138
  keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">,
@@ -395,3 +395,16 @@ export type TypedArray =
395
395
  | Uint16Array
396
396
  | Int32Array
397
397
  | Uint32Array;
398
+
399
+ /**
400
+ * JSON Web Key Value.
401
+ * JWKs are not supported for now, since webcrypto doesn't support exporting key/pairs
402
+ */
403
+ export type JWKValue = null | boolean | number | string | string[] | JWK;
404
+
405
+ /**
406
+ * Object representable with JSON Web Key.
407
+ */
408
+ export interface JWK {
409
+ [key: string]: JWKValue;
410
+ }
k6/index.d.ts CHANGED
@@ -36,6 +36,7 @@ import "./experimental/tracing";
36
36
  import "./experimental/webcrypto";
37
37
  import "./experimental/websockets";
38
38
  import "./experimental/grpc";
39
+ import "./timers";
39
40
  import "./ws";
40
41
  import "./net/grpc";
41
42
 
k6/options.d.ts CHANGED
@@ -47,6 +47,9 @@ export interface Options {
47
47
  /** Third party collector configuration. */
48
48
  ext?: { [name: string]: CollectorOptions };
49
49
 
50
+ /** Cloud options */
51
+ cloud?: CloudOptions;
52
+
50
53
  /** Static hostname mapping. */
51
54
  hosts?: { [name: string]: string };
52
55
 
@@ -139,6 +142,13 @@ export interface CollectorOptions {
139
142
  [name: string]: any;
140
143
  }
141
144
 
145
+ /**
146
+ * Options for the cloud.
147
+ */
148
+ export interface CloudOptions {
149
+ [name: string]: any;
150
+ }
151
+
142
152
  /**
143
153
  * Test stage.
144
154
  */
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.49.3",
3
+ "version": "0.50.1",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -60,6 +60,6 @@
60
60
  },
61
61
  "scripts": {},
62
62
  "dependencies": {},
63
- "typesPublisherContentHash": "eaa5e69f20d37937316cec29094022e50b7e7e7ebdac94b53e0c32540754bec4",
63
+ "typesPublisherContentHash": "2a8f07e9cc2b17f1c90d400665135022e7c3b213f384fe82ffa9ae439704d942",
64
64
  "typeScriptVersion": "4.7"
65
65
  }
k6/timers.d.ts ADDED
@@ -0,0 +1,47 @@
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;