@types/k6 0.46.3 → 0.47.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://k6.io/docs/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Thu, 14 Sep 2023 01:49:18 GMT
11
+ * Last updated: Tue, 10 Oct 2023 12:42:36 GMT
12
12
  * Dependencies: none
13
13
  * Global values: none
14
14
 
@@ -603,47 +603,52 @@ export interface BrowserContext {
603
603
  browser(): Browser;
604
604
 
605
605
  /**
606
- * Adds cookies into the `BrowserContext`.
606
+ * Adds {@link Cookie | cookies} into this {@link BrowserContext}.
607
+ *
608
+ * @param cookies The {@link Cookie | cookies} to add to this {@link BrowserContext}.
609
+ * @example
610
+ * ```js
611
+ * context.addCookies([
612
+ * { name: 'foo', value: 'foovalue', sameSite: 'Lax', url: 'https://k6.io' },
613
+ * { name: 'bar', value: 'barvalue', sameSite: 'Strict', domain: 'test.k6.io', path: '/bar' },
614
+ * ]);
615
+ * ```
607
616
  */
608
- addCookies(
609
- cookies: Array<{
610
- name: string;
611
-
612
- value: string;
613
-
614
- /**
615
- * either url or domain / path are required.
616
- */
617
- url?: string;
618
-
619
- /**
620
- * either url or domain / path are required.
621
- */
622
- domain?: string;
623
-
624
- /**
625
- * either url or domain / path are required.
626
- */
627
- path?: string;
628
-
629
- /**
630
- * Unix time in seconds.
631
- */
632
- expires?: number;
633
-
634
- httpOnly?: boolean;
635
-
636
- secure?: boolean;
637
-
638
- sameSite?: "Strict" | "Lax" | "None";
639
- }>,
640
- ): void;
617
+ addCookies(cookies: Cookie[]): void;
641
618
 
642
619
  /**
643
- * Clear the `BrowserContext`'s cookies.
620
+ * Clears the {@link Cookie | cookies} in this {@link BrowserContext}.
621
+ *
622
+ * @example
623
+ * ```js
624
+ * context.addCookies([{ name: 'foo', value: 'bar', url: 'https://k6.io' }]);
625
+ * context.cookies().length; // 1
626
+ * context.clearCookies();
627
+ * context.cookies().length; // 0
628
+ * ```
644
629
  */
645
630
  clearCookies(): void;
646
631
 
632
+ /**
633
+ * Retrieves the {@link Cookie | cookies} in this {@link BrowserContext} filtered by provided URLs,
634
+ * or all {@link Cookie | cookies} if no URLs are provided.
635
+ *
636
+ * @param urls URLs to filter {@link Cookie | cookies} by.
637
+ * @returns An array of {@link Cookie | cookies}.
638
+ * @example
639
+ * ```js
640
+ * // Get all cookies in the browser context
641
+ * const cookies = context.cookies();
642
+ *
643
+ * // Get all cookies for the specified URLs
644
+ * const cookies = context.cookies('https://k6.io', 'https://test.k6.io');
645
+ *
646
+ * // Get all cookies for the specified URLs and filter by name
647
+ * const cookies = context.cookies('https://k6.io', 'https://test.k6.io').filter(c => c.name === 'foo');
648
+ * ```
649
+ */
650
+ cookies(...urls: string[]): Cookie[];
651
+
647
652
  /**
648
653
  * Clears all permission overrides for the `BrowserContext`.
649
654
  */
@@ -772,6 +777,145 @@ export interface BrowserContext {
772
777
  ): Page | null;
773
778
  }
774
779
 
780
+ /**
781
+ * {@link ConsoleMessage} objects are dispatched by page via the
782
+ * `page.on('console')` event. For each console message logged in the page,
783
+ * k6 browser delivers it to the registered handlers.
784
+ *
785
+ * ```js
786
+ * // Listen for all console log messages in the browser page and output them
787
+ * // in the test logs
788
+ * page.on('console', msg => console.log(msg.text()));
789
+ *
790
+ * // Listen for all console events and handle errors
791
+ * page.on('console', msg => {
792
+ * if (msg.type() === 'error')
793
+ * console.log(`Error text: "${msg.text()}"`);
794
+ * });
795
+ *
796
+ * // Deconstruct console log arguments
797
+ * await msg.args()[0].jsonValue(); // hello
798
+ * await msg.args()[1].jsonValue(); // 42
799
+ * ```
800
+ */
801
+ export interface ConsoleMessage {
802
+ /**
803
+ * List of arguments passed to a `console` function call. See also
804
+ * `page.on('console')`.
805
+ */
806
+ args(): JSHandle[];
807
+
808
+ /**
809
+ * The page that produced this console message, if any.
810
+ */
811
+ page(): null | Page;
812
+
813
+ /**
814
+ * The text of the console message.
815
+ */
816
+ text(): string;
817
+
818
+ /**
819
+ * One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`,
820
+ * `'warning'`, `'dir'`, `'dirxml'`, `'table'`, `'trace'`, `'clear'`,
821
+ * `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`,
822
+ * `'profile'`, `'profileEnd'`, `'count'`, `'timeEnd'`.
823
+ */
824
+ type(): string;
825
+ }
826
+
827
+ /**
828
+ * {@link Cookie} represents a cookie in a {@link BrowserContext}.
829
+ *
830
+ * @see
831
+ * {@link BrowserContext} has methods to {@link BrowserContext.addCookies | add}, {@link BrowserContext.cookies | query} and {@link BrowserContext.clearCookies | clear} cookies.
832
+ */
833
+ export interface Cookie {
834
+ /**
835
+ * The {@link Cookie | cookie}'s name.
836
+ *
837
+ * @defaultValue
838
+ * The default is `''`.
839
+ */
840
+ name: string;
841
+
842
+ /**
843
+ * The {@link Cookie | cookie}'s value.
844
+ *
845
+ * @defaultValue
846
+ * The default is `''`.
847
+ */
848
+ value: string;
849
+
850
+ /**
851
+ * The {@link Cookie | cookie}'s URL.
852
+ *
853
+ * Required unless one of {@link Cookie.domain | domain} or {@link Cookie.path | path} are specified.
854
+ */
855
+ url?: string;
856
+
857
+ /**
858
+ * The {@link Cookie | cookie}'s domain.
859
+ *
860
+ * Required unless one of {@link Cookie.url | url} or {@link Cookie.path | path} are specified.
861
+ */
862
+ domain?: string;
863
+
864
+ /**
865
+ * The {@link Cookie | cookie}'s path.
866
+ *
867
+ * Required unless one of {@link Cookie.url | url} or {@link Cookie.domain | domain} are specified.
868
+ *
869
+ * @defaultValue
870
+ * The default is `'/'`.
871
+ */
872
+ path?: string;
873
+
874
+ /**
875
+ * The {@link Cookie | cookie}'s expiration date as the number of seconds since the UNIX epoch.
876
+ *
877
+ * If omitted, the {@link Cookie | cookie} becomes a session cookie.
878
+ *
879
+ * @defaultValue
880
+ * The default is `-1`, meaning a session cookie.
881
+ */
882
+ expires?: number;
883
+
884
+ /**
885
+ * Whether the {@link Cookie | cookie} is http-only.
886
+ *
887
+ * @defaultValue
888
+ * The default is `false`.
889
+ */
890
+ httpOnly?: boolean;
891
+
892
+ /**
893
+ * Whether the {@link Cookie | cookie} is secure.
894
+ *
895
+ * @defaultValue
896
+ * The default is `false`.
897
+ */
898
+ secure?: boolean;
899
+
900
+ /**
901
+ * The {@link Cookie | cookie}'s same-site status.
902
+ *
903
+ * It can be one of `'Strict'`, `'Lax'`, or `'None'`.
904
+ *
905
+ * @defaultValue
906
+ * The default is `'Lax'`.
907
+ */
908
+ sameSite?: CookieSameSite;
909
+ }
910
+
911
+ /**
912
+ * CookieSameSite represents the same-site status of a {@link Cookie | cookie}.
913
+ *
914
+ * @defaultValue
915
+ * The default is `'Lax'`.
916
+ */
917
+ export type CookieSameSite = "Strict" | "Lax" | "None";
918
+
775
919
  /**
776
920
  * ElementHandle represents an in-page DOM element.
777
921
  */
@@ -2461,6 +2605,28 @@ export interface Page {
2461
2605
  */
2462
2606
  mouse: Mouse;
2463
2607
 
2608
+ /**
2609
+ * Emitted when JavaScript within the page calls one of console API methods
2610
+ * , e.g. `console.log` or `console.dir`. Also emitted if the page throws
2611
+ * an error or a warning.
2612
+ *
2613
+ * The arguments passed into `console.log` are available on the
2614
+ * {@link ConsoleMessage} event handler argument.
2615
+ *
2616
+ * **Usage**
2617
+ *
2618
+ * ```js
2619
+ * page.on('console', msg => {
2620
+ * const values = [];
2621
+ * for (const arg of msg.args())
2622
+ * values.push(arg.jsonValue());
2623
+ * console.log(...values);
2624
+ * });
2625
+ * page.evaluate(() => console.log('hello', 5, { foo: 'bar' }));
2626
+ * ```
2627
+ */
2628
+ on(event: "console", listener: (consoleMessage: ConsoleMessage) => void): void;
2629
+
2464
2630
  /**
2465
2631
  * Returns the page that opened the current page. The first page that is
2466
2632
  * navigated to will have a null opener.
k6/experimental/grpc.d.ts CHANGED
@@ -28,6 +28,11 @@ export interface ConnectParams {
28
28
  */
29
29
  reflect?: boolean;
30
30
 
31
+ /**
32
+ * Metadata to send with reflection request.
33
+ */
34
+ reflectMetadata?: object;
35
+
31
36
  /**
32
37
  * Connection timeout to use.
33
38
  */
k6/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for k6 0.46
1
+ // Type definitions for k6 0.47
2
2
  // Project: https://k6.io/docs/
3
3
  // Definitions by: Mihail Stoykov <https://github.com/MStoykov>
4
4
  // Ivan <https://github.com/codebien>
k6/net/grpc.d.ts CHANGED
@@ -28,6 +28,11 @@ export interface ConnectParams {
28
28
  */
29
29
  reflect?: boolean;
30
30
 
31
+ /**
32
+ * Metadata to send with reflection request.
33
+ */
34
+ reflectMetadata?: object;
35
+
31
36
  /**
32
37
  * Connection timeout to use.
33
38
  */
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.46.3",
3
+ "version": "0.47.0",
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": "7adc75fe3ab6a575e652d2a25bba71079e68f3751d3d268561f73356b442c089",
63
+ "typesPublisherContentHash": "b079f39833a2ebca3ed4f12e4348669f4051f51b63a4eaff08300e42a0ee50c7",
64
64
  "typeScriptVersion": "4.5"
65
65
  }