@types/k6 1.1.0 → 1.2.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, 01 Jul 2025 22:02:09 GMT
11
+ * Last updated: Wed, 13 Aug 2025 11:02:39 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
k6/browser/index.d.ts CHANGED
@@ -1377,6 +1377,19 @@ export interface ElementHandle extends JSHandle {
1377
1377
 
1378
1378
  /**
1379
1379
  * Select one or more options of a `<select>` element which match the values.
1380
+ *
1381
+ * @example
1382
+ * ```js
1383
+ * // Single selection matching the value or label
1384
+ * handle.selectOption('blue');
1385
+ *
1386
+ * // single selection matching the label
1387
+ * handle.selectOption({ label: 'Blue' });
1388
+ *
1389
+ * // multiple selection
1390
+ * handle.selectOption(['red', 'green', 'blue']);
1391
+ * ```
1392
+ *
1380
1393
  * @param values Values of options to select.
1381
1394
  * @param options Element handle options.
1382
1395
  * @returns List of selected options.
@@ -1567,6 +1580,19 @@ export interface Frame {
1567
1580
  /**
1568
1581
  * Select the given options and return the array of option values of the first element
1569
1582
  * found that matches the selector.
1583
+ *
1584
+ * @example
1585
+ * ```js
1586
+ * // Single selection matching the value or label
1587
+ * frame.selectOption('blue');
1588
+ *
1589
+ * // single selection matching the label
1590
+ * frame.selectOption({ label: 'Blue' });
1591
+ *
1592
+ * // multiple selection
1593
+ * frame.selectOption(['red', 'green', 'blue']);
1594
+ * ```
1595
+ *
1570
1596
  * @param selector The selector to use.
1571
1597
  * @param values The values to select.
1572
1598
  * @returns The array of option values of the first element found.
@@ -1841,7 +1867,83 @@ export interface Frame {
1841
1867
  * @param options The options to use.
1842
1868
  * @returns A promise that resolves to the response of the navigation when it happens.
1843
1869
  */
1844
- waitForNavigation(options?: ContentLoadOptions): Promise<Response | null>;
1870
+ waitForNavigation(options?: {
1871
+ /**
1872
+ * Maximum operation time in milliseconds. Defaults to `30` seconds. The
1873
+ * default value can be changed via the
1874
+ * browserContext.setDefaultNavigationTimeout(timeout),
1875
+ * browserContext.setDefaultTimeout(timeout),
1876
+ * page.setDefaultNavigationTimeout(timeout) or
1877
+ * page.setDefaultTimeout(timeout) methods.
1878
+ *
1879
+ * Setting the value to `0` will disable the timeout.
1880
+ */
1881
+ timeout?: number;
1882
+
1883
+ /**
1884
+ * An exact string or regex pattern to match while waiting for the
1885
+ * navigation. Note that if the parameter is a string, the method will
1886
+ * wait for navigation to URL that is exactly equal to the string.
1887
+ */
1888
+ url?: string | RegExp;
1889
+
1890
+ /**
1891
+ * When to consider operation succeeded, defaults to `load`. Events can be
1892
+ * either:
1893
+ * - `'domcontentloaded'` - consider operation to be finished when the
1894
+ * `DOMContentLoaded` event is fired.
1895
+ * - `'load'` - consider operation to be finished when the `load` event is
1896
+ * fired.
1897
+ * - `'networkidle'` - **DISCOURAGED** consider operation to be finished
1898
+ * when there are no network connections for at least `500` ms. Don't use
1899
+ * this method for testing especially with chatty websites where the event
1900
+ * may never fire, rely on web assertions to assess readiness instead.
1901
+ */
1902
+ waitUntil?: "load" | "domcontentloaded" | "networkidle";
1903
+ }): Promise<Response | null>;
1904
+
1905
+ /**
1906
+ * Waits for the page to navigate to the specified URL.
1907
+ *
1908
+ * @example
1909
+ * ```js
1910
+ * await page.locator('a[href="/login"]').click();
1911
+ * await page.waitForURL(/.*\/login$/);
1912
+ * ```
1913
+ *
1914
+ * @param url An exact match or regular expression to match the URL.
1915
+ * @param options Options to use.
1916
+ */
1917
+ waitForURL(
1918
+ url: string | RegExp,
1919
+ options?: {
1920
+ /**
1921
+ * Maximum operation time in milliseconds. Defaults to `30` seconds.
1922
+ * The default value can be changed via the
1923
+ * browserContext.setDefaultNavigationTimeout(timeout),
1924
+ * browserContext.setDefaultTimeout(timeout),
1925
+ * page.setDefaultNavigationTimeout(timeout) or
1926
+ * page.setDefaultTimeout(timeout) methods.
1927
+ *
1928
+ * Setting the value to `0` will disable the timeout.
1929
+ */
1930
+ timeout?: number;
1931
+
1932
+ /**
1933
+ * When to consider operation succeeded, defaults to `load`. Events can be
1934
+ * either:
1935
+ * - `'domcontentloaded'` - consider operation to be finished when the
1936
+ * `DOMContentLoaded` event is fired.
1937
+ * - `'load'` - consider operation to be finished when the `load` event is
1938
+ * fired.
1939
+ * - `'networkidle'` - **DISCOURAGED** consider operation to be finished
1940
+ * when there are no network connections for at least `500` ms. Don't use
1941
+ * this method for testing especially with chatty websites where the event
1942
+ * may never fire, rely on web assertions to assess readiness instead.
1943
+ */
1944
+ waitUntil?: "load" | "domcontentloaded" | "networkidle";
1945
+ },
1946
+ ): Promise<void>;
1845
1947
 
1846
1948
  /**
1847
1949
  * Wait for the given selector to match the waiting criteria.
@@ -1965,6 +2067,21 @@ export interface Keyboard {
1965
2067
  * React, Vue, etc.
1966
2068
  */
1967
2069
  export interface Locator {
2070
+ /**
2071
+ * Returns an array of locators matching the selector.
2072
+ *
2073
+ * **Usage**
2074
+ *
2075
+ * ```js
2076
+ * // Select all options
2077
+ * for (const option of await page.locator('option').all())
2078
+ * await option.click();
2079
+ * ```
2080
+ *
2081
+ * @returns Array of locators
2082
+ */
2083
+ all(): Promise<Locator[]>;
2084
+
1968
2085
  /**
1969
2086
  * Clears text boxes and input fields of any existing values.
1970
2087
  *
@@ -2149,6 +2266,19 @@ export interface Locator {
2149
2266
  /**
2150
2267
  * Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
2151
2268
  * otherwise only the first option matching one of the passed options is selected.
2269
+ *
2270
+ * @example
2271
+ * ```js
2272
+ * // Single selection matching the value or label
2273
+ * locator.selectOption('blue');
2274
+ *
2275
+ * // single selection matching the label
2276
+ * locator.selectOption({ label: 'Blue' });
2277
+ *
2278
+ * // multiple selection
2279
+ * locator.selectOption(['red', 'green', 'blue']);
2280
+ * ```
2281
+ *
2152
2282
  * @param values Values of options to select.
2153
2283
  * @param options Options to use.
2154
2284
  * @returns List of selected options.
@@ -2700,6 +2830,336 @@ export interface Page {
2700
2830
  },
2701
2831
  ): Promise<string | null>;
2702
2832
 
2833
+ /**
2834
+ * Returns {@link Locator} to the element with the corresponding role.
2835
+ *
2836
+ * @example
2837
+ * ```js
2838
+ * const locator = page.getByRole('button', { name: 'Pizza, Please!' });
2839
+ *
2840
+ * await locator.click();
2841
+ * ```
2842
+ *
2843
+ * @param role The role of the element.
2844
+ * @param options Options to use.
2845
+ * @returns The locator to the element with the corresponding role.
2846
+ */
2847
+ getByRole(
2848
+ role:
2849
+ | "alert"
2850
+ | "alertdialog"
2851
+ | "application"
2852
+ | "article"
2853
+ | "banner"
2854
+ | "blockquote"
2855
+ | "button"
2856
+ | "caption"
2857
+ | "cell"
2858
+ | "checkbox"
2859
+ | "code"
2860
+ | "columnheader"
2861
+ | "combobox"
2862
+ | "complementary"
2863
+ | "contentinfo"
2864
+ | "definition"
2865
+ | "dialog"
2866
+ | "directory"
2867
+ | "document"
2868
+ | "emphasis"
2869
+ | "feed"
2870
+ | "figure"
2871
+ | "form"
2872
+ | "generic"
2873
+ | "grid"
2874
+ | "gridcell"
2875
+ | "group"
2876
+ | "heading"
2877
+ | "img"
2878
+ | "insertion"
2879
+ | "link"
2880
+ | "list"
2881
+ | "listbox"
2882
+ | "listitem"
2883
+ | "log"
2884
+ | "main"
2885
+ | "marquee"
2886
+ | "math"
2887
+ | "menu"
2888
+ | "menubar"
2889
+ | "menuitem"
2890
+ | "menuitemcheckbox"
2891
+ | "menuitemradio"
2892
+ | "meter"
2893
+ | "navigation"
2894
+ | "none"
2895
+ | "note"
2896
+ | "option"
2897
+ | "presentation"
2898
+ | "progressbar"
2899
+ | "radio"
2900
+ | "radiogroup"
2901
+ | "region"
2902
+ | "row"
2903
+ | "rowgroup"
2904
+ | "rowheader"
2905
+ | "scrollbar"
2906
+ | "search"
2907
+ | "searchbox"
2908
+ | "separator"
2909
+ | "slider"
2910
+ | "spinbutton"
2911
+ | "status"
2912
+ | "strong"
2913
+ | "subscript"
2914
+ | "superscript"
2915
+ | "switch"
2916
+ | "tab"
2917
+ | "table"
2918
+ | "tablist"
2919
+ | "tabpanel"
2920
+ | "term"
2921
+ | "textbox"
2922
+ | "time"
2923
+ | "timer"
2924
+ | "toolbar"
2925
+ | "tooltip"
2926
+ | "tree"
2927
+ | "treegrid"
2928
+ | "treeitem",
2929
+ options?: {
2930
+ /**
2931
+ * Whether the accessible `options.name` should be checked exactly for equality.
2932
+ *
2933
+ * @defaultValue false
2934
+ */
2935
+ exact?: boolean;
2936
+
2937
+ /**
2938
+ * Whether to include elements that are normally excluded from the accessibility tree.
2939
+ *
2940
+ * @defaultValue false
2941
+ */
2942
+ includeHidden?: boolean;
2943
+
2944
+ /**
2945
+ * A number attribute that is traditionally used for headings h1-h6.
2946
+ */
2947
+ level?: number;
2948
+
2949
+ /**
2950
+ * An accessible name for the element, such as a text in a button or a label for an input.
2951
+ */
2952
+ name?: string | RegExp;
2953
+
2954
+ /**
2955
+ * A boolean attribute that can be used to indicate if a checkbox is checked or not.
2956
+ */
2957
+ checked?: boolean;
2958
+
2959
+ /**
2960
+ * A boolean attribute that can be used to indicate if an element is disabled or not.
2961
+ */
2962
+ disabled?: boolean;
2963
+
2964
+ /**
2965
+ * A boolean attribute that can be used to indicate if an element is expanded or not.
2966
+ */
2967
+ expanded?: boolean;
2968
+
2969
+ /**
2970
+ * A boolean attribute that can be used to indicate if an element is pressed or not.
2971
+ */
2972
+ pressed?: boolean;
2973
+
2974
+ /**
2975
+ * A boolean attribute that can be used to indicate if an element is selected or not.
2976
+ */
2977
+ selected?: boolean;
2978
+ },
2979
+ ): Locator;
2980
+
2981
+ /**
2982
+ * Returns {@link Locator} to the element with the corresponding alt text.
2983
+ *
2984
+ * @example
2985
+ * ```js
2986
+ * const locator = page.getByAltText('pizza');
2987
+ *
2988
+ * await locator.click();
2989
+ * ```
2990
+ *
2991
+ * @param altText The alt text of the element.
2992
+ * @param options Options to use.
2993
+ * @returns The locator to the element with the corresponding alt text.
2994
+ */
2995
+ getByAltText(
2996
+ altText: string | RegExp,
2997
+ options?: {
2998
+ /**
2999
+ * Whether the locator should be exact.
3000
+ *
3001
+ * @defaultValue false
3002
+ */
3003
+ exact?: boolean;
3004
+ },
3005
+ ): Locator;
3006
+
3007
+ /**
3008
+ * Returns {@link Locator} to the element with the corresponding label text.
3009
+ *
3010
+ * @example
3011
+ * ```js
3012
+ * const locator = page.getByLabel('Password');
3013
+ *
3014
+ * await locator.fill('my-password');
3015
+ * ```
3016
+ *
3017
+ * @param label The label text of the element.
3018
+ * @param options Options to use.
3019
+ * @returns The locator to the element with the corresponding label text.
3020
+ */
3021
+ getByLabel(
3022
+ label: string | RegExp,
3023
+ options?: {
3024
+ /**
3025
+ * Whether the locator should be exact.
3026
+ *
3027
+ * @defaultValue false
3028
+ */
3029
+ exact?: boolean;
3030
+ },
3031
+ ): Locator;
3032
+
3033
+ /**
3034
+ * Allows locating elements by their text content. Returns {@link Locator}.
3035
+ *
3036
+ * Consider the following DOM structure:
3037
+ *
3038
+ * ```html
3039
+ * <div>Hello <span>world</span></div>
3040
+ * <div>Hello</div>
3041
+ * ```
3042
+ *
3043
+ * You can locate by text substring, exact string, or a regular expression:
3044
+ *
3045
+ * @example
3046
+ * ```js
3047
+ * // Matches <span>
3048
+ * page.getByText('world');
3049
+ *
3050
+ * // Matches first <div>
3051
+ * page.getByText('Hello world');
3052
+ *
3053
+ * // Matches second <div>
3054
+ * page.getByText('Hello', { exact: true });
3055
+ *
3056
+ * // Matches both <div>s
3057
+ * page.getByText(/Hello/);
3058
+ *
3059
+ * // Matches second <div>
3060
+ * page.getByText(/^hello$/i);
3061
+ * ```
3062
+ *
3063
+ * Matching by text always normalizes whitespace, even with exact match. For
3064
+ * example, it turns multiple spaces into one, turns line breaks into spaces
3065
+ * and ignores leading and trailing whitespace.
3066
+ *
3067
+ * Input elements of the type `button` and `submit` are matched by their
3068
+ * `value` instead of the text content. For example, locating by text
3069
+ * `"Log in"` matches `<input type=button value="Log in">`.
3070
+ *
3071
+ * @param text Text to locate the element by.
3072
+ * @param options Options to use.
3073
+ * @returns The locator to the element with the corresponding text content.
3074
+ */
3075
+ getByText(
3076
+ text: string | RegExp,
3077
+ options?: {
3078
+ /**
3079
+ * Whether to find an exact match: case-sensitive and whole-string.
3080
+ * Default to false. Ignored when locating by a regular expression.
3081
+ * Note that exact match still trims whitespace.
3082
+ *
3083
+ * @defaultValue false
3084
+ */
3085
+ exact?: boolean;
3086
+ },
3087
+ ): Locator;
3088
+
3089
+ /**
3090
+ * Returns {@link Locator} to the element with the corresponding test ID.
3091
+ * Note that this method only supports the `data-testid` attribute.
3092
+ *
3093
+ * @example
3094
+ * HTML:
3095
+ * ```html
3096
+ * <button data-testid="submit-button">Submit</button>
3097
+ * ```
3098
+ *
3099
+ * JavaScript:
3100
+ * ```js
3101
+ * const locator = page.getByTestId('submit-button');
3102
+ *
3103
+ * await locator.click();
3104
+ * ```
3105
+ *
3106
+ * @param testId The test ID of the element.
3107
+ * @returns The locator to the element with the corresponding test ID.
3108
+ */
3109
+ getByTestId(testId: string | RegExp): Locator;
3110
+
3111
+ /**
3112
+ * Returns {@link Locator} to the element with the corresponding placeholder text.
3113
+ *
3114
+ * @example
3115
+ * ```js
3116
+ * const locator = page.getByPlaceholder('name@example.com');
3117
+ *
3118
+ * await locator.fill('my.name@example.com');
3119
+ * ```
3120
+ *
3121
+ * @param placeholder The placeholder text of the element.
3122
+ * @param options Options to use.
3123
+ * @returns The locator to the element with the corresponding placeholder text.
3124
+ */
3125
+ getByPlaceholder(
3126
+ placeholder: string | RegExp,
3127
+ options?: {
3128
+ /**
3129
+ * Whether the locator should be exact.
3130
+ *
3131
+ * @defaultValue false
3132
+ */
3133
+ exact?: boolean;
3134
+ },
3135
+ ): Locator;
3136
+
3137
+ /**
3138
+ * Returns {@link Locator} to the element with the corresponding title text.
3139
+ *
3140
+ * @example
3141
+ * ```js
3142
+ * const locator = page.getByTitle('Information box');
3143
+ *
3144
+ * await locator.click();
3145
+ * ```
3146
+ *
3147
+ * @param title The title text of the element.
3148
+ * @param options Options to use.
3149
+ * @returns The locator to the element with the corresponding title text.
3150
+ */
3151
+ getByTitle(
3152
+ title: string | RegExp,
3153
+ options?: {
3154
+ /**
3155
+ * Whether the locator should be exact.
3156
+ *
3157
+ * @defaultValue false
3158
+ */
3159
+ exact?: boolean;
3160
+ },
3161
+ ): Locator;
3162
+
2703
3163
  /**
2704
3164
  * Navigates to the specified url and returns the main resource response.
2705
3165
  *
@@ -3218,6 +3678,16 @@ export interface Page {
3218
3678
  waitUntil?: "load" | "domcontentloaded" | "networkidle";
3219
3679
  }): Promise<Response | null>;
3220
3680
 
3681
+ /**
3682
+ * Adds a route to the page to modify network requests made by that page.
3683
+ *
3684
+ * Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
3685
+ */
3686
+ route(
3687
+ url: string | RegExp,
3688
+ handler: (route: Route) => any,
3689
+ ): Promise<void>;
3690
+
3221
3691
  /**
3222
3692
  * Returns the buffer with the captured screenshot from the browser.
3223
3693
  *
@@ -3273,6 +3743,18 @@ export interface Page {
3273
3743
  * This select one or more options which match the values from a <select>
3274
3744
  * element.
3275
3745
  *
3746
+ * @example
3747
+ * ```js
3748
+ * // Single selection matching the value or label
3749
+ * page.selectOption('#colors-options', 'blue');
3750
+ *
3751
+ * // single selection matching the label
3752
+ * page.selectOption('#colors-options', { label: 'Blue' });
3753
+ *
3754
+ * // multiple selection
3755
+ * page.selectOption('#colors-options', ['red', 'green', 'blue']);
3756
+ * ```
3757
+ *
3276
3758
  * @param selector A selector to search for an element. If there are multiple
3277
3759
  * elements satisfying the selector, the first will be used.
3278
3760
  * @param values Options to select. If the select has multiple attribute, all
@@ -3787,6 +4269,13 @@ export interface Page {
3787
4269
  */
3788
4270
  timeout?: number;
3789
4271
 
4272
+ /**
4273
+ * An exact string or regex pattern to match while waiting for the
4274
+ * navigation. Note that if the parameter is a string, the method will
4275
+ * wait for navigation to URL that is exactly equal to the string.
4276
+ */
4277
+ url?: string | RegExp;
4278
+
3790
4279
  /**
3791
4280
  * When to consider operation succeeded, defaults to `load`. Events can be
3792
4281
  * either:
@@ -3802,6 +4291,49 @@ export interface Page {
3802
4291
  waitUntil?: "load" | "domcontentloaded" | "networkidle";
3803
4292
  }): Promise<Response | null>;
3804
4293
 
4294
+ /**
4295
+ * Waits for the page to navigate to the specified URL.
4296
+ *
4297
+ * @example
4298
+ * ```js
4299
+ * await page.locator('a[href="/login"]').click();
4300
+ * await page.waitForURL(/.*\/login$/);
4301
+ * ```
4302
+ *
4303
+ * @param url An exact match or regular expression to match the URL.
4304
+ * @param options Options to use.
4305
+ */
4306
+ waitForURL(
4307
+ url: string | RegExp,
4308
+ options?: {
4309
+ /**
4310
+ * Maximum operation time in milliseconds. Defaults to `30` seconds.
4311
+ * The default value can be changed via the
4312
+ * browserContext.setDefaultNavigationTimeout(timeout),
4313
+ * browserContext.setDefaultTimeout(timeout),
4314
+ * page.setDefaultNavigationTimeout(timeout) or
4315
+ * page.setDefaultTimeout(timeout) methods.
4316
+ *
4317
+ * Setting the value to `0` will disable the timeout.
4318
+ */
4319
+ timeout?: number;
4320
+
4321
+ /**
4322
+ * When to consider operation succeeded, defaults to `load`. Events can be
4323
+ * either:
4324
+ * - `'domcontentloaded'` - consider operation to be finished when the
4325
+ * `DOMContentLoaded` event is fired.
4326
+ * - `'load'` - consider operation to be finished when the `load` event is
4327
+ * fired.
4328
+ * - `'networkidle'` - **DISCOURAGED** consider operation to be finished
4329
+ * when there are no network connections for at least `500` ms. Don't use
4330
+ * this method for testing especially with chatty websites where the event
4331
+ * may never fire, rely on web assertions to assess readiness instead.
4332
+ */
4333
+ waitUntil?: "load" | "domcontentloaded" | "networkidle";
4334
+ },
4335
+ ): Promise<void>;
4336
+
3805
4337
  /**
3806
4338
  * **NOTE** Use web assertions that assert visibility or a locator-based
3807
4339
  * locator.waitFor([options]) instead.
@@ -4089,6 +4621,112 @@ export interface Response {
4089
4621
  url(): string;
4090
4622
  }
4091
4623
 
4624
+ /**
4625
+ * Route represents a network request intercepted by page.route() function and allows to modify its behavior.
4626
+ *
4627
+ * Once routing is enabled, every request intercepted by a route will stall unless it's continued, fulfilled or aborted.
4628
+ * When several routes match the given pattern, they run in the order opposite to their registration.
4629
+ * That way the last registered route can always override all the previous ones.
4630
+ */
4631
+ export interface Route {
4632
+ /**
4633
+ * Aborts the request with the given error code.
4634
+ *
4635
+ * **Usage**
4636
+ *
4637
+ * ```js
4638
+ * // Abort all images requests
4639
+ * await page.route(/(\.png$)|(\.jpg$)/, async (route) => {
4640
+ * await route.abort();
4641
+ * });
4642
+ * ```
4643
+ *
4644
+ * @param errorCode The error code to abort the request with, can be one of the following:
4645
+ * 'aborted', 'accessdenied', 'addressunreachable', 'blockedbyclient', 'blockedbyresponse', 'connectionaborted','connectionclosed',
4646
+ * 'connectionfailed', 'connectionrefused', 'connectionreset', 'internetdisconnected', 'namenotresolved', 'timedout', 'failed'.
4647
+ */
4648
+ abort(errorCode: string): Promise<void>;
4649
+
4650
+ /**
4651
+ * Continues the request with optional overrides.
4652
+ *
4653
+ * **Usage**
4654
+ *
4655
+ * ```js
4656
+ * await page.route('**\/*', async (route, request) => {
4657
+ * // Override headers
4658
+ * const headers = {
4659
+ * ...request.headers(),
4660
+ * foo: 'foo-value', // set "foo" header
4661
+ * bar: undefined, // remove "bar" header
4662
+ * };
4663
+ * await route.continue({ headers });
4664
+ * });
4665
+ * ```
4666
+ *
4667
+ * @param options Optional overrides for the request.
4668
+ */
4669
+ continue(options?: {
4670
+ /**
4671
+ * Optional HTTP headers to override.
4672
+ */
4673
+ headers?: { [key: string]: string };
4674
+ /**
4675
+ * Optional method to override the request method (e.g., 'GET', 'POST').
4676
+ */
4677
+ method?: string;
4678
+ /**
4679
+ * Optional post data to override the request body.
4680
+ */
4681
+ postData?: string | ArrayBuffer;
4682
+ /**
4683
+ * Optional URL to override the request URL.
4684
+ */
4685
+ url?: string;
4686
+ }): Promise<void>;
4687
+
4688
+ /**
4689
+ * Fulfills the request with the given response.
4690
+ *
4691
+ * **Usage**
4692
+ * ```js
4693
+ * // Respond with a custom JSON response
4694
+ * await page.route('**\/*', async (route) => {
4695
+ * await route.fulfill({
4696
+ * status: 200,
4697
+ * contentType: 'application/json',
4698
+ * body: JSON.stringify({ message: 'Hello, world!' }),
4699
+ * });
4700
+ * });
4701
+ * ```
4702
+ *
4703
+ * @param options The response options to fulfill the request with.
4704
+ */
4705
+ fulfill(options: {
4706
+ /**
4707
+ * Optional body of the response, can be a string or an ArrayBuffer.
4708
+ */
4709
+ body?: string | ArrayBuffer;
4710
+ /**
4711
+ * Optional content type of the response.
4712
+ */
4713
+ contentType?: string;
4714
+ /**
4715
+ * Optional HTTP headers to return.
4716
+ */
4717
+ headers?: { [key: string]: string };
4718
+ /**
4719
+ * Optional HTTP status code to return. Defaults to `200`.
4720
+ */
4721
+ status?: number;
4722
+ }): Promise<void>;
4723
+
4724
+ /**
4725
+ * Returns the matching request that this route is handling.
4726
+ */
4727
+ request(): Request;
4728
+ }
4729
+
4092
4730
  /**
4093
4731
  * Touchscreen provides an api for interacting with a virtual touchscreen. It
4094
4732
  * operates in main-frame CSS pixels relative to the top-left corner of the
k6/execution/index.d.ts CHANGED
@@ -62,7 +62,7 @@ export const instance: {
62
62
  export const test: {
63
63
  /**
64
64
  * Aborts the test run with the exit code 108.
65
- * https://grafana.com/docs/k6/latest/javascript-api/k6-execution/#test
65
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-execution/#test-abort
66
66
  * @param input - Aborted message.
67
67
  * @example
68
68
  * import exec from "k6/execution";
@@ -71,6 +71,18 @@ export const test: {
71
71
  */
72
72
  abort(input?: string): void;
73
73
 
74
+ /**
75
+ * Marks the test as failed with the exit code 110, without interrupting execution.
76
+ * This allows all iterations to complete while reporting the run as failed.
77
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-execution/#test-fail
78
+ * @param message - Failure reason.
79
+ * @example
80
+ * import exec from "k6/execution";
81
+ * exec.test.fail();
82
+ * exec.test.fail('this is the reason');
83
+ */
84
+ fail(message?: string): void;
85
+
74
86
  options: Options;
75
87
  };
76
88
 
k6/net/grpc/index.d.ts CHANGED
@@ -104,6 +104,21 @@ export interface GrpcError {
104
104
  message: string;
105
105
  }
106
106
 
107
+ /**
108
+ * Health check status values as defined by the gRPC Health Checking Protocol.
109
+ */
110
+ export type HealthCheckStatus = "SERVING" | "NOT_SERVING" | "UNKNOWN";
111
+
112
+ /**
113
+ * Response from a gRPC health check.
114
+ */
115
+ export interface HealthCheckResponse {
116
+ /**
117
+ * The health status of the service.
118
+ */
119
+ Status: HealthCheckStatus;
120
+ }
121
+
107
122
  /**
108
123
  * gRPC client to interact with a gRPC server.
109
124
  * https://grafana.com/docs/k6/latest/javascript-api/k6-net-grpc/client/
@@ -130,6 +145,15 @@ export class Client {
130
145
 
131
146
  /** Close the connection. */
132
147
  close(): void;
148
+
149
+ /**
150
+ * Performs a health check on the gRPC service.
151
+ * Uses the standard gRPC Health Checking Protocol.
152
+ *
153
+ * @param service - Optional service name to check. If not provided, checks overall server health.
154
+ * @returns The health check response
155
+ */
156
+ healthCheck(service?: string): HealthCheckResponse;
133
157
  }
134
158
 
135
159
  /**
@@ -215,4 +239,9 @@ export const StatusUnavailable: number;
215
239
  export const StatusDataLoss: number;
216
240
  export const StatusUnauthenticated: number;
217
241
 
242
+ export const HealthCheckServing: HealthCheckStatus;
243
+ export const HealthCheckNotServing: HealthCheckStatus;
244
+ export const HealthCheckUnknown: HealthCheckStatus;
245
+ export const HealthCheckServiceUnkown: HealthCheckStatus;
246
+
218
247
  export * as default from "k6/net/grpc";
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -69,6 +69,6 @@
69
69
  "scripts": {},
70
70
  "dependencies": {},
71
71
  "peerDependencies": {},
72
- "typesPublisherContentHash": "96515089683437758fefd2c656f0f92f85fe68f378af7dbdfaad6cf5321acd13",
73
- "typeScriptVersion": "5.1"
72
+ "typesPublisherContentHash": "40595b1c8223b9f31a5529cf4204696a178b1b02ca743dd2e773c271702a1f7c",
73
+ "typeScriptVersion": "5.2"
74
74
  }