@types/k6 0.44.1 → 0.44.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,7 +1,21 @@
1
- /**
2
- * This module provides an experimental implementation that brings browser
3
- * test automation to the k6 testing platform.
4
- */
1
+ import {
2
+ BrowserContext,
3
+ EvaluationArgument,
4
+ PageFunction,
5
+ SelectOptionsObject,
6
+ KeyboardModifier,
7
+ MouseButton,
8
+ ScreenshotOptions,
9
+ NavigationOptions } from "./";
10
+ import { Touchscreen } from "./touchscreen";
11
+ import { Response } from "./response";
12
+ import { Locator } from "./locator";
13
+ import { JSHandle } from "./js_handle";
14
+ import { Keyboard } from "./keyboard";
15
+ import { Mouse } from "./mouse";
16
+ import { ElementHandle } from "./element_handle";
17
+ import { Frame } from "./frame";
18
+ import { Worker } from "./worker";
5
19
 
6
20
  /**
7
21
  * Page provides methods to interact with a single tab in a running web browser
@@ -82,7 +96,7 @@ export class Page {
82
96
  * The mouse button (`left`, `middle` or `right`) to use during the action.
83
97
  * Defaults to `left`.
84
98
  */
85
- button?: "left"|"right"|"middle";
99
+ button?: MouseButton;
86
100
 
87
101
  /**
88
102
  * The number of times the action is performed. Defaults to `1`.
@@ -105,7 +119,7 @@ export class Page {
105
119
  * action. If not specified, currently pressed modifiers are used,
106
120
  * otherwise defaults to `null`.
107
121
  */
108
- modifiers?: Array<"Alt"|"Control"|"Meta"|"Shift">;
122
+ modifiers?: KeyboardModifier[];
109
123
 
110
124
  /**
111
125
  * If set to `true` and a navigation occurs from performing this action, it
@@ -175,7 +189,7 @@ export class Page {
175
189
  * The mouse button (`left`, `middle` or `right`) to use during the action.
176
190
  * Defaults to `left`.
177
191
  */
178
- button?: "left"|"right"|"middle";
192
+ button?: MouseButton;
179
193
 
180
194
  /**
181
195
  * Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
@@ -193,7 +207,7 @@ export class Page {
193
207
  * action. If not specified, currently pressed modifiers are used,
194
208
  * otherwise defaults to `null`.
195
209
  */
196
- modifiers?: Array<"Alt"|"Control"|"Meta"|"Shift">;
210
+ modifiers?: KeyboardModifier[];
197
211
 
198
212
  /**
199
213
  * If set to `true` and a navigation occurs from performing this action, it
@@ -438,39 +452,7 @@ export class Page {
438
452
  * `https://`.
439
453
  * @param options
440
454
  */
441
- goto(url: string, options?: {
442
- /**
443
- * Referer header value.
444
- */
445
- referer?: string;
446
-
447
- /**
448
- * Maximum operation time in milliseconds. Defaults to `30` seconds. The
449
- * default value can be changed via the
450
- * browserContext.setDefaultNavigationTimeout(timeout),
451
- * browserContext.setDefaultTimeout(timeout),
452
- * page.setDefaultNavigationTimeout(timeout) or
453
- * page.setDefaultTimeout(timeout) methods.
454
- *
455
- * Setting the value to `0` will disable the timeout.
456
- *
457
- */
458
- timeout?: number;
459
-
460
- /**
461
- * When to consider operation succeeded, defaults to `load`. Events can be
462
- * either:
463
- * - `'domcontentloaded'` - consider operation to be finished when the
464
- * `DOMContentLoaded` event is fired.
465
- * - `'load'` - consider operation to be finished when the `load` event is
466
- * fired.
467
- * - `'networkidle'` - **DISCOURAGED** consider operation to be finished
468
- * when there are no network connections for at least `500` ms. Don't use
469
- * this method for testing especially with chatty websites where the event
470
- * may never fire, rely on web assertions to assess readiness instead.
471
- */
472
- waitUntil?: "load"|"domcontentloaded"|"networkidle";
473
- }): Promise<null|Response>;
455
+ goto(url: string, options?: NavigationOptions): Promise<null|Response>;
474
456
 
475
457
  /**
476
458
  * **NOTE** Use locator-based locator.hover([options]) instead.
@@ -493,7 +475,7 @@ export class Page {
493
475
  * action. If not specified, currently pressed modifiers are used,
494
476
  * otherwise defaults to `null`.
495
477
  */
496
- modifiers?: Array<"Alt"|"Control"|"Meta"|"Shift">;
478
+ modifiers?: KeyboardModifier[];
497
479
 
498
480
  /**
499
481
  * If set to `true` and a navigation occurs from performing this action, it
@@ -942,31 +924,7 @@ export class Page {
942
924
  * the currently visible viewport. Defaults to `false`.
943
925
  */
944
926
  fullPage?: boolean;
945
-
946
- /**
947
- * Hides default white background and allows capturing screenshots with
948
- * transparency. Not applicable to `jpeg` images. Defaults to `false`.
949
- */
950
- omitBackground?: boolean;
951
-
952
- /**
953
- * The file path to save the image to. The screenshot type will be inferred
954
- * from file extension. If `path` is a relative path, then it is resolved
955
- * relative to the current working directory. If no path is provided, the
956
- * image won't be saved to the disk.
957
- */
958
- path?: string;
959
-
960
- /**
961
- * The quality of the image, between 0-100; `jpeg` only.
962
- */
963
- quality?: number;
964
-
965
- /**
966
- * Specify screenshot type, defaults to `png`.
967
- */
968
- type?: "png"|"jpeg";
969
- }): ArrayBuffer;
927
+ } & ScreenshotOptions): ArrayBuffer;
970
928
 
971
929
  /**
972
930
  * **NOTE** Use locator-based locator.selectOption(values[, options]) instead.
@@ -1113,7 +1071,7 @@ export class Page {
1113
1071
  * action. If not specified, currently pressed modifiers are used,
1114
1072
  * otherwise defaults to `null`.
1115
1073
  */
1116
- modifiers?: Array<"Alt"|"Control"|"Meta"|"Shift">;
1074
+ modifiers?: KeyboardModifier[];
1117
1075
 
1118
1076
  /**
1119
1077
  * If set to `true` and a navigation occurs from performing this action, it
@@ -1472,102 +1430,3 @@ export class Page {
1472
1430
  */
1473
1431
  $$(selector: string): ElementHandle[];
1474
1432
  }
1475
-
1476
- /**
1477
- * `BrowserContexts` provide a way to operate multiple independent sessions, with
1478
- * separate pages, cache, and cookies.
1479
- */
1480
- export class BrowserContext {}
1481
-
1482
- /**
1483
- * JSHandle represents an in-page JavaScript object.
1484
- */
1485
- export class JSHandle<T = any> {}
1486
-
1487
- /**
1488
- * Frame represents the frame within a page. A page is made up of hierarchy of frames.
1489
- */
1490
- export class Frame {}
1491
-
1492
- /**
1493
- * Response class represents responses which are received by page.
1494
- */
1495
- export class Response {}
1496
-
1497
- /**
1498
- * Keyboard provides an api for managing a virtual keyboard.
1499
- */
1500
- export class Keyboard {}
1501
-
1502
- /**
1503
- * Mouse provides an api for managing a virtual mouse.
1504
- */
1505
- export class Mouse {}
1506
-
1507
- /**
1508
- * The Locator API makes it easier to work with dynamically changing elements.
1509
- * Some of the benefits of using it over existing ways to locate an element
1510
- * (e.g. Page.$()) include:
1511
- *
1512
- * - Helps with writing robust tests by finding an element even if the
1513
- * underlying frame navigates.
1514
- * - Makes it easier to work with dynamic web pages and SPAs built with Svelte,
1515
- * React, Vue, etc.
1516
- */
1517
- export class Locator {}
1518
-
1519
- /**
1520
- * ElementHandle represents an in-page DOM element.
1521
- */
1522
- export class ElementHandle {}
1523
-
1524
- /**
1525
- * Touchscreen provides an api for interacting with a virtual touchscreen. It
1526
- * in main-frame CSS pixels relative to the top-left corner of the viewport.
1527
- */
1528
- export class Touchscreen {}
1529
-
1530
- /**
1531
- * The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
1532
- */
1533
- export class Worker {}
1534
-
1535
- /**
1536
- * Represents event-specific properties. Refer to the events documentation for
1537
- * the lists of initial properties:
1538
- * - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
1539
- * - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
1540
- * - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
1541
- * - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
1542
- * - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
1543
- * - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
1544
- * - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
1545
- */
1546
- export type EvaluationArgument = object;
1547
-
1548
- export type PageFunction<Arg, R> = string | ((arg: Unboxed<Arg>) => R);
1549
-
1550
- export type Unboxed<Arg> =
1551
- Arg extends [infer A0, infer A1] ? [Unboxed<A0>, Unboxed<A1>] :
1552
- Arg extends [infer A0, infer A1, infer A2] ? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>] :
1553
- Arg extends [infer A0, infer A1, infer A2, infer A3] ? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>, Unboxed<A3>] :
1554
- Arg extends Array<infer T> ? Array<Unboxed<T>> :
1555
- Arg extends object ? { [Key in keyof Arg]: Unboxed<Arg[Key]> } :
1556
- Arg;
1557
-
1558
- export interface SelectOptionsObject {
1559
- /**
1560
- * Matches by `option.value`.
1561
- */
1562
- value?: string;
1563
-
1564
- /**
1565
- * Matches by `option.label`.
1566
- */
1567
- label?: string;
1568
-
1569
- /**
1570
- * Matches by the index.
1571
- */
1572
- index?: number;
1573
- }
@@ -0,0 +1,101 @@
1
+ import { ResourceType, ResourceTiming } from "./";
2
+ import { Response } from "./response";
3
+ import { Frame } from "./frame";
4
+
5
+ /**
6
+ * Request class represents requests which are sent by a page.
7
+ */
8
+ export class Request {
9
+ /**
10
+ * An object with HTTP headers associated with the request. All header names are
11
+ * lower-case.
12
+ * @returns The headers object.
13
+ */
14
+ allHeaders(): Record<string, string>;
15
+
16
+ /**
17
+ * @returns the Frame that initiated this request
18
+ */
19
+ frame(): Frame;
20
+
21
+ /**
22
+ * An object with HTTP headers associated with the request. All header names are
23
+ * lower-case.
24
+ * @returns An object with HTTP headers associated with the request.
25
+ */
26
+ headers(): Record<string, string>;
27
+
28
+ /**
29
+ * An array with all the request HTTP headers. Unlike `Request.allHeaders()`,
30
+ * header names are not lower-cased. Headers with multiple entries, such as
31
+ * `Set-Cookie`, appear in the array multiple times.
32
+ * @returns An array of all the request HTTP headers.
33
+ */
34
+ headersArray(): Array<{ name: string; value: string }>;
35
+
36
+ /**
37
+ * Retuns the value of the header matching the name. The name is case insensitive.
38
+ * @param name Header name to retrieve value for.
39
+ * @returns The value of the header matching the name.
40
+ */
41
+ headerValue(name: string): string | null;
42
+
43
+ /**
44
+ * @returns a boolean stating whether the request is for a navigation
45
+ */
46
+ isNavigationRequest(): boolean;
47
+
48
+ /**
49
+ * Request's method (GET, POST, etc.)
50
+ * @returns request's method name
51
+ */
52
+ method(): string;
53
+
54
+ /**
55
+ * Contains the request's post body, if any.
56
+ * @returns request's post body
57
+ */
58
+ postData(): string;
59
+
60
+ /**
61
+ * Request's post body in a binary form, if any.
62
+ * @returns an ArrayBuffer with request's post data
63
+ */
64
+ postDataBuffer(): ArrayBuffer | null;
65
+
66
+ /**
67
+ * Contains the request's resource type as it was perceived by the rendering engine.
68
+ * ResourceType will be one of the following: `document`, `stylesheet`, `image`,
69
+ * `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
70
+ * `websocket`, `manifest`, `other`.
71
+ * @returns resource type name
72
+ */
73
+ resourceType(): ResourceType;
74
+
75
+ /**
76
+ * Returns the matching `Response` object, or `null` if the response was not received
77
+ * due to error.
78
+ * @returns The `Response` object, or `null` if the response was not received due to error.
79
+ */
80
+ response(): Response | null;
81
+
82
+ /**
83
+ * Returns resource size information for given request.
84
+ * @returns Resource size information for given request.
85
+ */
86
+ size(): { body: number; headers: number };
87
+
88
+ /**
89
+ * Returns resource timing information for given request. Most of the timing values
90
+ * become available upon the response, `responseEnd` becomes available when request
91
+ * finishes.
92
+ * @returns Resource timing information for given request.
93
+ */
94
+ timing(): ResourceTiming;
95
+
96
+ /**
97
+ * URL of the request.
98
+ * @returns request URL
99
+ */
100
+ url(): string;
101
+ }
@@ -0,0 +1,115 @@
1
+ import { SecurityDetailsObject } from './';
2
+ import { Request } from "./request";
3
+ import { Frame } from "./frame";
4
+
5
+ /**
6
+ * Response class represents responses which are received by page.
7
+ */
8
+ export class Response {
9
+ /**
10
+ * An object with HTTP headers associated with the response. All header names are
11
+ * lower-case.
12
+ * @returns The headers object.
13
+ */
14
+ allHeaders(): Record<string, string>;
15
+
16
+ /**
17
+ * Returns the response body.
18
+ * @returns A buffer with response body.
19
+ */
20
+ body(): ArrayBuffer;
21
+
22
+ /**
23
+ * @returns the Frame that initiated this response
24
+ */
25
+ frame(): Frame;
26
+
27
+ /**
28
+ * An object with HTTP headers associated with the response. All header names are
29
+ * lower-case.
30
+ * @returns The headers object.
31
+ */
32
+ headers(): Record<string, string>;
33
+
34
+ /**
35
+ * An array with all the request HTTP response headers. Unlike `Response.headers()`, header
36
+ * names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`,
37
+ * appear in the array multiple times.
38
+ * @returns An array of all the request HTTP headers.
39
+ */
40
+ headersArray(): Array<{ name: string, value: string }>;
41
+
42
+ /**
43
+ * Returns the value of the header matching the name. The name is case insensitive.
44
+ * If multiple headers have the same name (except `Set-Cookie`), they are returned
45
+ * as a list separated by ``,``. For `Set-Cookie`, the `\n` separator is used. If
46
+ * no headers are found, `null` is returned.
47
+ * @param name Header name to retrieve value for.
48
+ * @returns The header value for the given name.
49
+ */
50
+ headerValue(name: string): string|null;
51
+
52
+ /**
53
+ * Returns all values of the headers matching the name, for example `set-cookie`.
54
+ * The name is case insensitive.
55
+ * @param name Header name to retrieve values for.
56
+ * @returns An array of header values for the given name.
57
+ */
58
+ headerValues(name: string): string[];
59
+
60
+ /**
61
+ * Returns the JSON representation of response body. Throws if response body is not
62
+ * parsable via `JSON.parse`.
63
+ * @returns JSON representation of response body.
64
+ */
65
+ json(): any;
66
+
67
+ /**
68
+ * Contains a boolean stating whether the response was successful (status in the
69
+ * range 200-299) or not.
70
+ * @returns a boolean stating whether the response was successful
71
+ */
72
+ ok(): boolean;
73
+
74
+ /**
75
+ * The request that was used to produce the response.
76
+ * @returns the matching `Request` object
77
+ */
78
+ request(): Request;
79
+
80
+ /**
81
+ * Security details associated with this response.
82
+ * @returns A matching `SecurityDetailsObject`
83
+ */
84
+ securityDetails(): SecurityDetailsObject|null;
85
+
86
+ /**
87
+ * Returns the IP address and port of the server for this response.
88
+ * @returns The IP address and port of the server
89
+ */
90
+ serverAddr(): { ipAddress: string; port: number }|null;
91
+
92
+ /**
93
+ * Contains the status code of the response (e.g., 200 for a success).
94
+ * @returns the status code of the response
95
+ */
96
+ status(): number;
97
+
98
+ /**
99
+ * Contains the status text of the response (e.g. usually an "OK" for a success).
100
+ * @returns the status text of the response
101
+ */
102
+ statusText(): string;
103
+
104
+ /**
105
+ * The size of the response body and the headers.
106
+ * @returns The size of the response body and the headers.
107
+ */
108
+ size(): { body: number; headers: number };
109
+
110
+ /**
111
+ * Contains the URL of the response.
112
+ * @returns the URL of the response
113
+ */
114
+ url(): string;
115
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Touchscreen provides an api for interacting with a virtual touchscreen. It
3
+ * operates in main-frame CSS pixels relative to the top-left corner of the
4
+ * viewport.
5
+ */
6
+ export class Touchscreen {
7
+ /**
8
+ * Taps on the specified position (`x`,`y`), which internally dispatches a `touchstart` and `touchend` event.
9
+ * @param x The x position.
10
+ * @param y The y position.
11
+ */
12
+ tap(x: number, y: number): void;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { PageFunction } from ".";
2
+ import { JSHandle } from "./js_handle";
3
+
4
+ /**
5
+ * The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
6
+ */
7
+ export class Worker {
8
+ /**
9
+ * Get the URL of the web worker.
10
+ * @return The URL of the web worker.
11
+ */
12
+ url(): string;
13
+ }
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.44.1",
3
+ "version": "0.44.2",
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": "682e46b4410e1338c96b7b05df4cb618809adceb3857d43f06b155bfbd799e21",
63
+ "typesPublisherContentHash": "195015b205e4b6aaf08d145b291e14fb39ef2fb1ca71b6d3b1cfb305b81593fb",
64
64
  "typeScriptVersion": "4.3"
65
65
  }