@types/k6 0.45.0 → 0.45.2

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.
@@ -1,389 +0,0 @@
1
- /**
2
- * This module provides an experimental implementation that brings browser
3
- * test automation to the k6 testing platform.
4
- */
5
-
6
- export { Page } from './page';
7
- export { Touchscreen } from './touchscreen';
8
- export { Request } from './request';
9
- export { Response } from './response';
10
- export { Locator } from './locator';
11
- export { JSHandle } from './js_handle';
12
- export { Keyboard } from './keyboard';
13
- export { ElementHandle } from './element_handle';
14
- export { Frame } from './frame';
15
- export { Worker } from './worker';
16
-
17
- /**
18
- * `BrowserContexts` provide a way to operate multiple independent sessions, with
19
- * separate pages, cache, and cookies.
20
- */
21
- export class BrowserContext {}
22
-
23
- /**
24
- * Represents event-specific properties. Refer to the events documentation for
25
- * the lists of initial properties:
26
- * - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
27
- * - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
28
- * - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
29
- * - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
30
- * - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
31
- * - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
32
- * - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
33
- */
34
- export type EvaluationArgument = object;
35
-
36
- export type PageFunction<Arg, R> = string | ((arg: Unboxed<Arg>) => R);
37
-
38
- export type Unboxed<Arg> = Arg extends [infer A0, infer A1]
39
- ? [Unboxed<A0>, Unboxed<A1>]
40
- : Arg extends [infer A0, infer A1, infer A2]
41
- ? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>]
42
- : Arg extends [infer A0, infer A1, infer A2, infer A3]
43
- ? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>, Unboxed<A3>]
44
- : Arg extends Array<infer T>
45
- ? Array<Unboxed<T>>
46
- : Arg extends object
47
- ? { [Key in keyof Arg]: Unboxed<Arg[Key]> }
48
- : Arg;
49
-
50
- export interface SelectOptionsObject {
51
- /**
52
- * Matches by `option.value`.
53
- */
54
- value?: string;
55
-
56
- /**
57
- * Matches by `option.label`.
58
- */
59
- label?: string;
60
-
61
- /**
62
- * Matches by the index.
63
- */
64
- index?: number;
65
- }
66
-
67
- export type ResourceType =
68
- | 'document'
69
- | 'stylesheet'
70
- | 'image'
71
- | 'media'
72
- | 'font'
73
- | 'script'
74
- | 'texttrack'
75
- | 'xhr'
76
- | 'fetch'
77
- | 'eventsource'
78
- | 'websocket'
79
- | 'manifest'
80
- | 'other';
81
- export type MouseButton = 'left' | 'right' | 'middle';
82
- export type KeyboardModifier = 'Alt' | 'Control' | 'Meta' | 'Shift';
83
- export type ElementState = 'attached' | 'detached' | 'visible' | 'hidden';
84
- export type InputElementState = ElementState | 'enabled' | 'disabled' | 'editable';
85
- export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle';
86
-
87
- export interface TimeoutOptions {
88
- /**
89
- * Maximum time in milliseconds. Pass 0 to disable the timeout. Default is overridden by the setDefaultTimeout option on `BrowserContext` or `Page`.
90
- * Defaults to 30000.
91
- */
92
- timeout?: number;
93
- }
94
-
95
- export interface StrictnessOptions {
96
- /**
97
- * When `true`, the call requires selector to resolve to a single element.
98
- * If given selector resolves to more than one element, the call throws
99
- * an exception. Defaults to `false`.
100
- */
101
- strict?: boolean;
102
- }
103
-
104
- export interface EventSequenceOptions {
105
- /**
106
- * Delay between events in milliseconds. Defaults to 0.
107
- */
108
- delay?: number;
109
- }
110
-
111
- export type ElementHandleOptions = {
112
- /**
113
- * Setting this to `true` will bypass the actionability checks (visible,
114
- * stable, enabled). Defaults to `false`.
115
- */
116
- force?: boolean;
117
-
118
- /**
119
- * If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete.
120
- * Defaults to `false`.
121
- */
122
- noWaitAfter?: boolean;
123
- } & TimeoutOptions;
124
-
125
- export type ElementHandlePointerOptions = ElementHandleOptions & {
126
- /**
127
- * Setting this to `true` will perform the actionability checks without
128
- * performing the action. Useful to wait until the element is ready for the
129
- * action without performing it. Defaults to `false`.
130
- */
131
- trial?: boolean;
132
- };
133
-
134
- export type ElementClickOptions = ElementHandlePointerOptions & {
135
- /**
136
- * A point to use relative to the top left corner of the element. If not supplied,
137
- * a visible point of the element is used.
138
- */
139
- position?: { x: number; y: number };
140
- };
141
-
142
- export interface KeyboardModifierOptions {
143
- /**
144
- * `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the action.
145
- * If not specified, currently pressed modifiers are used.
146
- */
147
- modifiers?: KeyboardModifier[];
148
- }
149
-
150
- export type KeyboardPressOptions = {
151
- /**
152
- * If set to `true` and a navigation occurs from performing this action, it
153
- * will not wait for it to complete. Defaults to `false`.
154
- */
155
- noWaitAfter?: boolean;
156
- } & EventSequenceOptions &
157
- TimeoutOptions;
158
-
159
- export type MouseMoveOptions = ElementClickOptions & KeyboardModifierOptions;
160
-
161
- export type MouseClickOptions = {
162
- /**
163
- * The mouse button to use during the action.
164
- * Defaults to `left`.
165
- */
166
- button?: MouseButton;
167
- } & EventSequenceOptions;
168
-
169
- export type MouseMultiClickOptions = MouseClickOptions & {
170
- /**
171
- * The number of times the action is performed.
172
- * Defaults to 1.
173
- */
174
- clickCount?: number;
175
- };
176
-
177
- export interface MouseDownUpOptions {
178
- /**
179
- * The mouse button to use during the action.
180
- * Defaults to `left`.
181
- */
182
- button?: MouseButton;
183
-
184
- /**
185
- * Defaults to 1.
186
- */
187
- clickCount?: number;
188
- }
189
-
190
- export type ContentLoadOptions = {
191
- /**
192
- * When to consider operation succeeded, defaults to `load`. Events can be
193
- * either:
194
- * - `'domcontentloaded'` - consider operation to be finished when the
195
- * `DOMContentLoaded` event is fired.
196
- * - `'load'` - consider operation to be finished when the `load` event is
197
- * fired.
198
- * - `'networkidle'` - **DISCOURAGED** consider operation to be finished
199
- * when there are no network connections for at least `500` ms. Don't use
200
- * this method for testing especially with chatty websites where the event
201
- * may never fire, rely on web assertions to assess readiness instead.
202
- */
203
- waitUntil?: LifecycleEvent;
204
- } & TimeoutOptions;
205
-
206
- export type NavigationOptions = {
207
- /**
208
- * Referer header value.
209
- */
210
- referer?: string;
211
- } & ContentLoadOptions;
212
-
213
- export interface ResourceTiming {
214
- /**
215
- * Request start time in milliseconds elapsed since January 1, 1970 00:00:00 UTC
216
- */
217
- startTime: number;
218
-
219
- /**
220
- * Time immediately before the browser starts the domain name lookup for the resource.
221
- * The value is given in milliseconds relative to `startTime`, -1 if not available.
222
- */
223
- domainLookupStart: number;
224
-
225
- /**
226
- * Time immediately after the browser ends the domain name lookup for the resource.
227
- * The value is given in milliseconds relative to `startTime`, -1 if not available.
228
- */
229
- domainLookupEnd: number;
230
-
231
- /**
232
- * Time immediately before the user agent starts establishing the connection to the server
233
- * to retrieve the resource. The value is given in milliseconds relative to `startTime`,
234
- * -1 if not available.
235
- */
236
- connectStart: number;
237
-
238
- /**
239
- * Time immediately before the browser starts the handshake process to secure the current
240
- * connection. The value is given in milliseconds relative to `startTime`, -1 if not available.
241
- */
242
- secureConnectionStart: number;
243
-
244
- /**
245
- * Time immediately after the user agent establishes the connection to the server
246
- * to retrieve the resource. The value is given in milliseconds relative to `startTime`,
247
- * -1 if not available.
248
- */
249
- connectEnd: number;
250
-
251
- /**
252
- * Time immediately before the browser starts requesting the resource from the server,
253
- * cache, or local resource. The value is given in milliseconds relative to `startTime`,
254
- * -1 if not available.
255
- */
256
- requestStart: number;
257
-
258
- /**
259
- * Time immediately after the browser receives the first byte of the response from the server,
260
- * cache, or local resource. The value is given in milliseconds relative to `startTime`,
261
- * -1 if not available.
262
- */
263
- responseStart: number;
264
-
265
- /**
266
- * Time immediately after the browser receives the last byte of the resource or immediately
267
- * before the transport connection is closed, whichever comes first. The value is given
268
- * in milliseconds relative to `startTime`, -1 if not available.
269
- */
270
- responseEnd: number;
271
- }
272
-
273
- export interface SecurityDetailsObject {
274
- /**
275
- * Common Name component of the Issuer field. The value is extracted from the
276
- * certificate. This should only be used for informational purposes.
277
- */
278
- issuer?: string;
279
-
280
- /**
281
- * The specific TLS protocol used. For example `TLS 1.3`.
282
- */
283
- protocol?: string;
284
-
285
- /**
286
- * Common Name component of the Subject field. The value is extracted from the
287
- * certificate. This should only be used for informational purposes.
288
- */
289
- subjectName?: string;
290
-
291
- /**
292
- * Unix timestamp (in seconds) specifying the exact date/time when this cert
293
- * becomes valid.
294
- */
295
- validFrom?: number;
296
-
297
- /**
298
- * Unix timestamp (in seconds) specifying the exact date/time when this cert
299
- * becomes invalid.
300
- */
301
- validTo?: number;
302
-
303
- /**
304
- * String with hex encoded SHA256 fingerprint of the certificate. The value is
305
- * extracted from the certificate.
306
- */
307
- sanList?: string[];
308
- }
309
-
310
- export interface Rect {
311
- /**
312
- * The x coordinate of the element in pixels.
313
- * (0, 0) is the top left corner of the viewport.
314
- */
315
- x: number;
316
-
317
- /**
318
- * The y coordinate of the element in pixels.
319
- * (0, 0) is the top left corner of the viewport.
320
- */
321
- y: number;
322
-
323
- /**
324
- * The width of the element in pixels.
325
- */
326
- width: number;
327
-
328
- /**
329
- * The height of the element in pixels.
330
- */
331
- height: number;
332
- }
333
-
334
- export type ImageFormat = 'jpeg' | 'png';
335
-
336
- export interface ScreenshotOptions {
337
- /**
338
- * The file path to save the image to. The screenshot type will be inferred from file extension.
339
- */
340
- path?: string;
341
-
342
- /**
343
- * The screenshot format.
344
- * @default 'png'
345
- */
346
- type?: ImageFormat;
347
-
348
- /**
349
- * Hide default white background and allow capturing screenshots with transparency.
350
- * Not applicable to `jpeg` images.
351
- * @default false
352
- */
353
- omitBackground?: boolean;
354
-
355
- /**
356
- * The quality of the image, between 0-100. Not applicable to `png` images.
357
- * @default 100
358
- */
359
- quality?: number;
360
- }
361
-
362
- /**
363
- * Methods to periodically check for a value.
364
- * - `raf` - use `requestAnimationFrame` callback to poll
365
- * - `mutation` - use a mutation observer
366
- * - `interval` - use a polling interval
367
- */
368
- export type PollingMethod = 'raf' | 'mutation' | 'interval';
369
-
370
- export interface PollingOptions {
371
- /**
372
- * Polling method to use.
373
- * @default 'raf'
374
- */
375
- polling?: 'raf' | 'mutation' | 'interval';
376
-
377
- /**
378
- * Polling interval in milliseconds if `polling` is set to `interval`.
379
- */
380
- interval?: number;
381
- }
382
-
383
- export interface ElementStateFilter {
384
- /**
385
- * The element state to filter for.
386
- * @default 'visible'
387
- */
388
- state?: ElementState;
389
- }
@@ -1,51 +0,0 @@
1
- import { PageFunction } from '.';
2
- import { ElementHandle } from './element_handle';
3
-
4
- /**
5
- * JSHandle represents an in-page JavaScript object.
6
- */
7
- export class JSHandle<T = any> {
8
- /**
9
- * Returns either `null` or the object handle itself, if the object handle is
10
- * an instance of `ElementHandle`.
11
- * @returns The ElementHandle if available.
12
- */
13
- asElement(): ElementHandle | null;
14
-
15
- /**
16
- * Stops referencing the element handle.
17
- */
18
- dispose(): void;
19
-
20
- /**
21
- * Evaluates the page function and returns its return value.
22
- * This method passes this handle as the first argument to the page function.
23
- * @param pageFunction The function to be evaluated.
24
- * @param args The arguments to pass to the page function.
25
- * @returns The return value of `pageFunction`.
26
- */
27
- evaluate<R, Arg>(pageFunction: PageFunction<R, Arg>, ...args: any): any;
28
-
29
- /**
30
- * Evaluates the page function and returns a `JSHandle`.
31
- * This method passes this handle as the first argument to the page function.
32
- * Unlike `evaluate`, `evaluateHandle` returns the value as a `JSHandle`
33
- * @param pageFunction The function to be evaluated.
34
- * @param args The arguments to pass to the page function.
35
- * @returns A JSHandle of the return value of `pageFunction`.
36
- */
37
- evaluateHandle<R, Arg>(pageFunction: PageFunction<R, Arg>, ...args: any): JSHandle<R>;
38
-
39
- /**
40
- * Fethes a map with own property names of of the `JSHandle` with their values as
41
- * `JSHandle` instances.
42
- * @returns A map with property names as keys and `JSHandle` instances for the property values.
43
- */
44
- getProperties(): Map<string, JSHandle>;
45
-
46
- /**
47
- * Fetches a JSON representation of the object.
48
- * @returns A JSON representation of the object.
49
- */
50
- jsonValue(): any;
51
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Keyboard provides an API for managing a virtual keyboard.
3
- */
4
- export class Keyboard {
5
- /**
6
- * Sends a key down message to a session target.
7
- * 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).
8
- * @param key Name of key to press, such as `ArrowLeft`.
9
- */
10
- down(key: string): void;
11
-
12
- /**
13
- * Dispatches an `input` event with the given `text`.
14
- * This method does not emit `keyDown`, `keyUp` or `keyPress` events.
15
- * @param text Event text.
16
- */
17
- insertText(text: string): void;
18
-
19
- /**
20
- * Sends a key press message to a session target.
21
- * A press message consists of successive key down and up messages.
22
- * @param key Sequence of keys to press.
23
- * @param options Specifies the typing options.
24
- */
25
- press(key: string, options?: { delay?: number }): void;
26
-
27
- /**
28
- * Type sends a `press` message to a session target for each character in text.
29
- * It sends an insertText message if a character is not among
30
- * valid characters in the keyboard's layout.
31
- * Modifier keys `Shift`, `Control`, `Alt`, `Meta` are _not_ respected.
32
- * @param text A text to type into a focused element.
33
- * @param options Specifies the typing options.
34
- */
35
- type(text: string, options?: { delay?: number }): void;
36
-
37
- /**
38
- * Sends a key up message to a session target.
39
- * 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).
40
- * @param key Name of key to release, such as `ArrowLeft`.
41
- */
42
- up(key: string): void;
43
- }
@@ -1,194 +0,0 @@
1
- import {
2
- MouseClickOptions,
3
- ElementClickOptions,
4
- KeyboardPressOptions,
5
- KeyboardModifierOptions,
6
- MouseMoveOptions,
7
- TimeoutOptions,
8
- ElementHandleOptions,
9
- EvaluationArgument,
10
- ElementState,
11
- MouseMultiClickOptions,
12
- StrictnessOptions,
13
- } from './';
14
-
15
- /**
16
- * The Locator API makes it easier to work with dynamically changing elements.
17
- * Some of the benefits of using it over existing ways to locate an element
18
- * (e.g. Page.$()) include:
19
- *
20
- * - Helps with writing robust tests by finding an element even if the
21
- * underlying frame navigates.
22
- * - Makes it easier to work with dynamic web pages and SPAs built with Svelte,
23
- * React, Vue, etc.
24
- */
25
- export class Locator {
26
- /**
27
- * Mouse click on the chosen element.
28
- * @param options Options to use.
29
- * @returns Promise which resolves when the element is successfully clicked.
30
- */
31
- click(options?: MouseMoveOptions & MouseMultiClickOptions & StrictnessOptions): Promise<void>;
32
-
33
- /**
34
- * Mouse double click on the chosen element.
35
- * @param options Options to use.
36
- */
37
- dblclick(options?: MouseMoveOptions & MouseMultiClickOptions & StrictnessOptions): void;
38
-
39
- /**
40
- * Use this method to select an `input type="checkbox"`.
41
- * @param options Options to use.
42
- */
43
- check(options?: ElementClickOptions & StrictnessOptions): void;
44
-
45
- /**
46
- * Use this method to unselect an `input type="checkbox"`.
47
- * @param options Options to use.
48
- */
49
- uncheck(options?: ElementClickOptions & StrictnessOptions): void;
50
-
51
- /**
52
- * Checks to see if the `input type="checkbox"` is selected or not.
53
- * @param options Options to use.
54
- * @returns `true` if the element is checked, `false` otherwise.
55
- */
56
- isChecked(options?: TimeoutOptions & StrictnessOptions): boolean;
57
-
58
- /**
59
- * Checks if the element is editable.
60
- * @param options Options to use.
61
- * @returns `true` if the element is editable, `false` otherwise.
62
- */
63
- isEditable(options?: TimeoutOptions): boolean;
64
-
65
- /**
66
- * Checks if the element is `enabled`.
67
- * @param options Options to use.
68
- * @returns `true` if the element is enabled, `false` otherwise.
69
- */
70
- isEnabled(options?: TimeoutOptions & StrictnessOptions): boolean;
71
-
72
- /**
73
- * Checks if the element is `disabled`.
74
- * @param options Options to use.
75
- * @returns `true` if the element is disabled, `false` otherwise.
76
- */
77
- isDisabled(options?: TimeoutOptions & StrictnessOptions): boolean;
78
-
79
- /**
80
- * Checks if the element is `visible`.
81
- * @param options Options to use.
82
- * @returns `true` if the element is visible, `false` otherwise.
83
- */
84
- isVisible(options?: TimeoutOptions & StrictnessOptions): boolean;
85
-
86
- /**
87
- * Checks if the element is `hidden`.
88
- * @param options Options to use.
89
- * @returns `true` if the element is hidden, `false` otherwise.
90
- */
91
- isHidden(options?: TimeoutOptions & StrictnessOptions): boolean;
92
-
93
- /**
94
- * Fill an `input`, `textarea` or `contenteditable` element with the provided value.
95
- * @param value Value to fill for the `input` or `textarea` element.
96
- * @param options Options to use.
97
- */
98
- fill(value: string, options?: ElementHandleOptions & StrictnessOptions): void;
99
-
100
- /**
101
- * Focuses the element using locator's selector.
102
- * @param options Options to use.
103
- */
104
- focus(options?: TimeoutOptions & StrictnessOptions): void;
105
-
106
- /**
107
- * Returns the element attribute value for the given attribute name.
108
- * @param name Attribute name to retrieve value for.
109
- * @param options Options to use.
110
- * @returns Attribute value.
111
- */
112
- getAttribute(name: string, options?: TimeoutOptions & StrictnessOptions): string | null;
113
-
114
- /**
115
- * Returns the `element.innerHTML`.
116
- * @param options Options to use.
117
- * @returns Element's innerHTML.
118
- */
119
- innerHTML(options?: TimeoutOptions & StrictnessOptions): string;
120
-
121
- /**
122
- * Returns the `element.innerText`.
123
- * @param options Options to use.
124
- * @returns Element's innerText.
125
- */
126
- innerText(options?: TimeoutOptions & StrictnessOptions): string;
127
-
128
- /**
129
- * Returns the `element.textContent`.
130
- * @param options Options to use.
131
- * @returns Element's textContent.
132
- */
133
- textContent(options?: TimeoutOptions & StrictnessOptions): string;
134
-
135
- /**
136
- * Returns `input.value` for the selected `input`, `textarea` or `select` element.
137
- * @param options Options to use.
138
- * @returns The input value of the element.
139
- */
140
- inputValue(options?: TimeoutOptions & StrictnessOptions): string;
141
-
142
- /**
143
- * Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
144
- * otherwise only the first option matching one of the passed options is selected.
145
- * @param values Values of options to select.
146
- * @param options Options to use.
147
- * @returns List of selected options.
148
- */
149
- selectOption(
150
- values: string | string[] | { value?: string; label?: string; index?: number },
151
- options?: ElementHandleOptions & StrictnessOptions,
152
- ): string[];
153
-
154
- /**
155
- * Press a single key on the keyboard or a combination of keys.
156
- * 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).
157
- * @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
158
- * @param options Keyboard press options.
159
- */
160
- press(key: string, options?: KeyboardPressOptions): void;
161
-
162
- /**
163
- * Type a text into the input field.
164
- * @param text Text to type into the input field.
165
- * @param options Typing options.
166
- */
167
- type(text: string, options?: KeyboardPressOptions): void;
168
-
169
- /**
170
- * Hover over the element.
171
- * @param options Options to use.
172
- */
173
- hover(options?: MouseMoveOptions & StrictnessOptions): void;
174
-
175
- /**
176
- * Tap on the chosen element.
177
- * @param options Options to use.
178
- */
179
- tap(options?: MouseMoveOptions & StrictnessOptions): void;
180
-
181
- /**
182
- * Dispatches HTML DOM event types e.g. `click`.
183
- * @param type DOM event type.
184
- * @param eventInit Event-specific properties.
185
- * @param options Options to use.
186
- */
187
- dispatchEvent(type: string, eventInit?: EvaluationArgument, options?: TimeoutOptions & StrictnessOptions): void;
188
-
189
- /**
190
- * Wait for the element to be in a particular state e.g. `visible`.
191
- * @param options Wait options.
192
- */
193
- waitFor(options?: { state?: ElementState } & TimeoutOptions & StrictnessOptions): void;
194
- }