@types/k6 0.47.3 → 0.49.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 +3 -3
- k6/crypto.d.ts +28 -28
- k6/data.d.ts +3 -3
- k6/encoding.d.ts +7 -7
- k6/execution.d.ts +2 -2
- k6/experimental/browser.d.ts +172 -88
- k6/experimental/fs.d.ts +102 -0
- k6/experimental/grpc.d.ts +8 -2
- k6/experimental/redis.d.ts +298 -90
- k6/experimental/tracing.d.ts +3 -3
- k6/experimental/webcrypto.d.ts +1 -1
- k6/experimental/websockets.d.ts +13 -13
- k6/global.d.ts +5 -5
- k6/html.d.ts +99 -99
- k6/http.d.ts +42 -42
- k6/index.d.ts +7 -6
- k6/metrics.d.ts +5 -5
- k6/net/grpc.d.ts +60 -2
- k6/options.d.ts +16 -16
- k6/package.json +8 -3
- k6/ws.d.ts +12 -12
k6/experimental/browser.d.ts
CHANGED
|
@@ -20,6 +20,40 @@ export type Unboxed<Arg> = Arg extends [infer A0, infer A1] ? [Unboxed<A0>, Unbo
|
|
|
20
20
|
: Arg extends object ? { [Key in keyof Arg]: Unboxed<Arg[Key]> }
|
|
21
21
|
: Arg;
|
|
22
22
|
|
|
23
|
+
/*
|
|
24
|
+
* CPUProfile is the mandatory input to be passed into {@link Page}'s
|
|
25
|
+
* `throttleCPU` method.
|
|
26
|
+
*/
|
|
27
|
+
export interface CPUProfile {
|
|
28
|
+
/*
|
|
29
|
+
* rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
|
|
30
|
+
*/
|
|
31
|
+
rate: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* NetworkProfile is the mandatory input to be passed into {@link Page}'s
|
|
36
|
+
* `throttleNetwork` method.
|
|
37
|
+
*/
|
|
38
|
+
export interface NetworkProfile {
|
|
39
|
+
/*
|
|
40
|
+
* Minimum latency from request sent to response headers received (ms).
|
|
41
|
+
*/
|
|
42
|
+
latency: number;
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* Maximal aggregated download throughput (bytes/sec). -1 disables download
|
|
46
|
+
* throttling.
|
|
47
|
+
*/
|
|
48
|
+
download: number;
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Maximal aggregated upload throughput (bytes/sec). -1 disables upload
|
|
52
|
+
* throttling.
|
|
53
|
+
*/
|
|
54
|
+
upload: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
23
57
|
export interface SelectOptionsObject {
|
|
24
58
|
/**
|
|
25
59
|
* Matches by `option.value`.
|
|
@@ -545,6 +579,12 @@ export const browser: Browser;
|
|
|
545
579
|
* `Browser` represents the main web browser instance.
|
|
546
580
|
*/
|
|
547
581
|
export interface Browser {
|
|
582
|
+
/**
|
|
583
|
+
* Closes the current `BrowserContext`. If there is no active
|
|
584
|
+
* `BrowserContext`, this method will throw an error.
|
|
585
|
+
*/
|
|
586
|
+
closeContext(): void;
|
|
587
|
+
|
|
548
588
|
/**
|
|
549
589
|
* Returns the current `BrowserContext`. There is a 1-to-1 mapping between
|
|
550
590
|
* `Browser` and `BrowserContext`. If no `BrowserContext` has been
|
|
@@ -650,7 +690,10 @@ export interface BrowserContext {
|
|
|
650
690
|
cookies(...urls: string[]): Cookie[];
|
|
651
691
|
|
|
652
692
|
/**
|
|
653
|
-
* Clears all permission overrides for the
|
|
693
|
+
* Clears all permission overrides for the {@link BrowserContext}.
|
|
694
|
+
* ```js
|
|
695
|
+
* context.clearPermissions();
|
|
696
|
+
* ```
|
|
654
697
|
*/
|
|
655
698
|
clearPermissions(): void;
|
|
656
699
|
|
|
@@ -660,7 +703,10 @@ export interface BrowserContext {
|
|
|
660
703
|
close(): void;
|
|
661
704
|
|
|
662
705
|
/**
|
|
663
|
-
* Grants specified permissions to the
|
|
706
|
+
* Grants specified permissions to the {@link BrowserContext}.
|
|
707
|
+
* ```js
|
|
708
|
+
* context.grantPermissions(['geolocation']);
|
|
709
|
+
* ```
|
|
664
710
|
*/
|
|
665
711
|
grantPermissions(
|
|
666
712
|
/**
|
|
@@ -741,40 +787,55 @@ export interface BrowserContext {
|
|
|
741
787
|
|
|
742
788
|
/**
|
|
743
789
|
* Waits for the event to fire and passes its value into the predicate
|
|
744
|
-
* function.
|
|
790
|
+
* function. Currently the only supported event is 'page' which when used will
|
|
791
|
+
* return the new {@link Page} that was created after `waitForEvent` was called.
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* ```js
|
|
795
|
+
* // Call waitForEvent with a predicate which will return true once at least
|
|
796
|
+
* // one page has been created.
|
|
797
|
+
* const promise = context.waitForEvent("page", { predicate: page => {
|
|
798
|
+
* if (++counter >= 1) {
|
|
799
|
+
* return true
|
|
800
|
+
* }
|
|
801
|
+
* return false
|
|
802
|
+
* } })
|
|
803
|
+
*
|
|
804
|
+
* // Now we create a page.
|
|
805
|
+
* const page = context.newPage()
|
|
806
|
+
*
|
|
807
|
+
* // Wait for the predicate to pass.
|
|
808
|
+
* await promise
|
|
809
|
+
* ```
|
|
745
810
|
*/
|
|
746
811
|
waitForEvent(
|
|
747
812
|
/**
|
|
748
|
-
* Name of event to wait for.
|
|
749
|
-
*
|
|
750
|
-
* NOTE: Currently this argument is disregarded, and waitForEvent will
|
|
751
|
-
* always wait for 'close' or 'page' events.
|
|
813
|
+
* Name of event to wait for. The only supported event is 'page'. If any
|
|
814
|
+
* other value is used an error will be thrown.
|
|
752
815
|
*/
|
|
753
|
-
event:
|
|
816
|
+
event: "page",
|
|
754
817
|
/**
|
|
755
|
-
*
|
|
756
|
-
*
|
|
818
|
+
* This is an optional argument. It can either be a predicate function or
|
|
819
|
+
* an options object.
|
|
757
820
|
*/
|
|
758
|
-
optionsOrPredicate
|
|
821
|
+
optionsOrPredicate?: {
|
|
759
822
|
/**
|
|
760
|
-
*
|
|
761
|
-
* The event data will be passed to it and it must return true
|
|
823
|
+
* Optional function that will be called when the {@link Page} event is
|
|
824
|
+
* emitted. The event data will be passed to it and it must return true
|
|
762
825
|
* to continue.
|
|
763
826
|
*
|
|
764
|
-
* If
|
|
827
|
+
* If {@link Page} is passed to predicate, this signals that a new page
|
|
765
828
|
* has been created.
|
|
766
|
-
* If null is passed to predicate, this signals that the page is
|
|
767
|
-
* closing.
|
|
768
829
|
*/
|
|
769
|
-
predicate
|
|
830
|
+
predicate?: (page: Page) => boolean;
|
|
770
831
|
|
|
771
832
|
/**
|
|
772
|
-
* Maximum time to wait in milliseconds.
|
|
773
|
-
*
|
|
833
|
+
* Maximum time to wait in milliseconds. Defaults to 30000 milliseconds or
|
|
834
|
+
* the timeout set by setDefaultTimeout on the {@link BrowserContext}.
|
|
774
835
|
*/
|
|
775
836
|
timeout?: number;
|
|
776
|
-
},
|
|
777
|
-
): Page
|
|
837
|
+
} | ((page: Page) => boolean),
|
|
838
|
+
): Promise<Page>;
|
|
778
839
|
}
|
|
779
840
|
|
|
780
841
|
/**
|
|
@@ -1408,7 +1469,7 @@ export interface Frame {
|
|
|
1408
1469
|
* @param options The options to use.
|
|
1409
1470
|
* @returns `true` if the element is hidden, `false` otherwise.
|
|
1410
1471
|
*/
|
|
1411
|
-
isHidden(selector: string, options?:
|
|
1472
|
+
isHidden(selector: string, options?: StrictnessOptions): boolean;
|
|
1412
1473
|
|
|
1413
1474
|
/**
|
|
1414
1475
|
* Get whether the first element found that matches the selector is visible or not.
|
|
@@ -1416,7 +1477,7 @@ export interface Frame {
|
|
|
1416
1477
|
* @param options The options to use.
|
|
1417
1478
|
* @returns `true` if the element is visible, `false` otherwise.
|
|
1418
1479
|
*/
|
|
1419
|
-
isVisible(selector: string, options?:
|
|
1480
|
+
isVisible(selector: string, options?: StrictnessOptions): boolean;
|
|
1420
1481
|
|
|
1421
1482
|
/**
|
|
1422
1483
|
* Wait for the given function to return a truthy value.
|
|
@@ -1563,37 +1624,51 @@ export interface Keyboard {
|
|
|
1563
1624
|
* React, Vue, etc.
|
|
1564
1625
|
*/
|
|
1565
1626
|
export interface Locator {
|
|
1627
|
+
/**
|
|
1628
|
+
* Clears text boxes and input fields of any existing values.
|
|
1629
|
+
*
|
|
1630
|
+
* **Usage**
|
|
1631
|
+
*
|
|
1632
|
+
* ```js
|
|
1633
|
+
* // Clears the input field matching the selector.
|
|
1634
|
+
* page.locator('input[name="login"]').clear();
|
|
1635
|
+
* ```
|
|
1636
|
+
*
|
|
1637
|
+
* @param options Options to use.
|
|
1638
|
+
*/
|
|
1639
|
+
clear(options?: ElementHandleOptions): void;
|
|
1640
|
+
|
|
1566
1641
|
/**
|
|
1567
1642
|
* Mouse click on the chosen element.
|
|
1568
1643
|
* @param options Options to use.
|
|
1569
1644
|
* @returns Promise which resolves when the element is successfully clicked.
|
|
1570
1645
|
*/
|
|
1571
|
-
click(options?: MouseMoveOptions & MouseMultiClickOptions
|
|
1646
|
+
click(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>;
|
|
1572
1647
|
|
|
1573
1648
|
/**
|
|
1574
1649
|
* Mouse double click on the chosen element.
|
|
1575
1650
|
* @param options Options to use.
|
|
1576
1651
|
*/
|
|
1577
|
-
dblclick(options?: MouseMoveOptions & MouseMultiClickOptions
|
|
1652
|
+
dblclick(options?: MouseMoveOptions & MouseMultiClickOptions): void;
|
|
1578
1653
|
|
|
1579
1654
|
/**
|
|
1580
1655
|
* Use this method to select an `input type="checkbox"`.
|
|
1581
1656
|
* @param options Options to use.
|
|
1582
1657
|
*/
|
|
1583
|
-
check(options?: ElementClickOptions
|
|
1658
|
+
check(options?: ElementClickOptions): void;
|
|
1584
1659
|
|
|
1585
1660
|
/**
|
|
1586
1661
|
* Use this method to unselect an `input type="checkbox"`.
|
|
1587
1662
|
* @param options Options to use.
|
|
1588
1663
|
*/
|
|
1589
|
-
uncheck(options?: ElementClickOptions
|
|
1664
|
+
uncheck(options?: ElementClickOptions): void;
|
|
1590
1665
|
|
|
1591
1666
|
/**
|
|
1592
1667
|
* Checks to see if the `input type="checkbox"` is selected or not.
|
|
1593
1668
|
* @param options Options to use.
|
|
1594
1669
|
* @returns `true` if the element is checked, `false` otherwise.
|
|
1595
1670
|
*/
|
|
1596
|
-
isChecked(options?: TimeoutOptions
|
|
1671
|
+
isChecked(options?: TimeoutOptions): boolean;
|
|
1597
1672
|
|
|
1598
1673
|
/**
|
|
1599
1674
|
* Checks if the element is editable.
|
|
@@ -1607,41 +1682,39 @@ export interface Locator {
|
|
|
1607
1682
|
* @param options Options to use.
|
|
1608
1683
|
* @returns `true` if the element is enabled, `false` otherwise.
|
|
1609
1684
|
*/
|
|
1610
|
-
isEnabled(options?: TimeoutOptions
|
|
1685
|
+
isEnabled(options?: TimeoutOptions): boolean;
|
|
1611
1686
|
|
|
1612
1687
|
/**
|
|
1613
1688
|
* Checks if the element is `disabled`.
|
|
1614
1689
|
* @param options Options to use.
|
|
1615
1690
|
* @returns `true` if the element is disabled, `false` otherwise.
|
|
1616
1691
|
*/
|
|
1617
|
-
isDisabled(options?: TimeoutOptions
|
|
1692
|
+
isDisabled(options?: TimeoutOptions): boolean;
|
|
1618
1693
|
|
|
1619
1694
|
/**
|
|
1620
1695
|
* Checks if the element is `visible`.
|
|
1621
|
-
* @param options Options to use.
|
|
1622
1696
|
* @returns `true` if the element is visible, `false` otherwise.
|
|
1623
1697
|
*/
|
|
1624
|
-
isVisible(
|
|
1698
|
+
isVisible(): boolean;
|
|
1625
1699
|
|
|
1626
1700
|
/**
|
|
1627
1701
|
* Checks if the element is `hidden`.
|
|
1628
|
-
* @param options Options to use.
|
|
1629
1702
|
* @returns `true` if the element is hidden, `false` otherwise.
|
|
1630
1703
|
*/
|
|
1631
|
-
isHidden(
|
|
1704
|
+
isHidden(): boolean;
|
|
1632
1705
|
|
|
1633
1706
|
/**
|
|
1634
1707
|
* Fill an `input`, `textarea` or `contenteditable` element with the provided value.
|
|
1635
1708
|
* @param value Value to fill for the `input` or `textarea` element.
|
|
1636
1709
|
* @param options Options to use.
|
|
1637
1710
|
*/
|
|
1638
|
-
fill(value: string, options?: ElementHandleOptions
|
|
1711
|
+
fill(value: string, options?: ElementHandleOptions): void;
|
|
1639
1712
|
|
|
1640
1713
|
/**
|
|
1641
1714
|
* Focuses the element using locator's selector.
|
|
1642
1715
|
* @param options Options to use.
|
|
1643
1716
|
*/
|
|
1644
|
-
focus(options?: TimeoutOptions
|
|
1717
|
+
focus(options?: TimeoutOptions): void;
|
|
1645
1718
|
|
|
1646
1719
|
/**
|
|
1647
1720
|
* Returns the element attribute value for the given attribute name.
|
|
@@ -1649,35 +1722,35 @@ export interface Locator {
|
|
|
1649
1722
|
* @param options Options to use.
|
|
1650
1723
|
* @returns Attribute value.
|
|
1651
1724
|
*/
|
|
1652
|
-
getAttribute(name: string, options?: TimeoutOptions
|
|
1725
|
+
getAttribute(name: string, options?: TimeoutOptions): string | null;
|
|
1653
1726
|
|
|
1654
1727
|
/**
|
|
1655
1728
|
* Returns the `element.innerHTML`.
|
|
1656
1729
|
* @param options Options to use.
|
|
1657
1730
|
* @returns Element's innerHTML.
|
|
1658
1731
|
*/
|
|
1659
|
-
innerHTML(options?: TimeoutOptions
|
|
1732
|
+
innerHTML(options?: TimeoutOptions): string;
|
|
1660
1733
|
|
|
1661
1734
|
/**
|
|
1662
1735
|
* Returns the `element.innerText`.
|
|
1663
1736
|
* @param options Options to use.
|
|
1664
1737
|
* @returns Element's innerText.
|
|
1665
1738
|
*/
|
|
1666
|
-
innerText(options?: TimeoutOptions
|
|
1739
|
+
innerText(options?: TimeoutOptions): string;
|
|
1667
1740
|
|
|
1668
1741
|
/**
|
|
1669
1742
|
* Returns the `element.textContent`.
|
|
1670
1743
|
* @param options Options to use.
|
|
1671
1744
|
* @returns Element's textContent.
|
|
1672
1745
|
*/
|
|
1673
|
-
textContent(options?: TimeoutOptions
|
|
1746
|
+
textContent(options?: TimeoutOptions): string;
|
|
1674
1747
|
|
|
1675
1748
|
/**
|
|
1676
1749
|
* Returns `input.value` for the selected `input`, `textarea` or `select` element.
|
|
1677
1750
|
* @param options Options to use.
|
|
1678
1751
|
* @returns The input value of the element.
|
|
1679
1752
|
*/
|
|
1680
|
-
inputValue(options?: TimeoutOptions
|
|
1753
|
+
inputValue(options?: TimeoutOptions): string;
|
|
1681
1754
|
|
|
1682
1755
|
/**
|
|
1683
1756
|
* Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
|
|
@@ -1688,7 +1761,7 @@ export interface Locator {
|
|
|
1688
1761
|
*/
|
|
1689
1762
|
selectOption(
|
|
1690
1763
|
values: string | string[] | { value?: string; label?: string; index?: number },
|
|
1691
|
-
options?: ElementHandleOptions
|
|
1764
|
+
options?: ElementHandleOptions,
|
|
1692
1765
|
): string[];
|
|
1693
1766
|
|
|
1694
1767
|
/**
|
|
@@ -1710,13 +1783,13 @@ export interface Locator {
|
|
|
1710
1783
|
* Hover over the element.
|
|
1711
1784
|
* @param options Options to use.
|
|
1712
1785
|
*/
|
|
1713
|
-
hover(options?: MouseMoveOptions
|
|
1786
|
+
hover(options?: MouseMoveOptions): void;
|
|
1714
1787
|
|
|
1715
1788
|
/**
|
|
1716
1789
|
* Tap on the chosen element.
|
|
1717
1790
|
* @param options Options to use.
|
|
1718
1791
|
*/
|
|
1719
|
-
tap(options?: MouseMoveOptions
|
|
1792
|
+
tap(options?: MouseMoveOptions): void;
|
|
1720
1793
|
|
|
1721
1794
|
/**
|
|
1722
1795
|
* Dispatches HTML DOM event types e.g. `click`.
|
|
@@ -1724,13 +1797,13 @@ export interface Locator {
|
|
|
1724
1797
|
* @param eventInit Event-specific properties.
|
|
1725
1798
|
* @param options Options to use.
|
|
1726
1799
|
*/
|
|
1727
|
-
dispatchEvent(type: string, eventInit?: EvaluationArgument, options?: TimeoutOptions
|
|
1800
|
+
dispatchEvent(type: string, eventInit?: EvaluationArgument, options?: TimeoutOptions): void;
|
|
1728
1801
|
|
|
1729
1802
|
/**
|
|
1730
1803
|
* Wait for the element to be in a particular state e.g. `visible`.
|
|
1731
1804
|
* @param options Wait options.
|
|
1732
1805
|
*/
|
|
1733
|
-
waitFor(options?: { state?: ElementState } & TimeoutOptions
|
|
1806
|
+
waitFor(options?: { state?: ElementState } & TimeoutOptions): void;
|
|
1734
1807
|
}
|
|
1735
1808
|
|
|
1736
1809
|
/**
|
|
@@ -2520,7 +2593,7 @@ export interface Page {
|
|
|
2520
2593
|
): boolean;
|
|
2521
2594
|
|
|
2522
2595
|
/**
|
|
2523
|
-
* **NOTE** Use locator-based locator.isHidden(
|
|
2596
|
+
* **NOTE** Use locator-based locator.isHidden() instead.
|
|
2524
2597
|
*
|
|
2525
2598
|
* Returns whether the element is hidden.
|
|
2526
2599
|
*
|
|
@@ -2528,29 +2601,10 @@ export interface Page {
|
|
|
2528
2601
|
* elements satisfying the selector, the first will be used.
|
|
2529
2602
|
* @param options
|
|
2530
2603
|
*/
|
|
2531
|
-
isHidden(
|
|
2532
|
-
selector: string,
|
|
2533
|
-
options?: {
|
|
2534
|
-
/**
|
|
2535
|
-
* When `true`, the call requires selector to resolve to a single element.
|
|
2536
|
-
* If given selector resolves to more than one element, the call throws
|
|
2537
|
-
* an exception. Defaults to `false`.
|
|
2538
|
-
*/
|
|
2539
|
-
strict?: boolean;
|
|
2540
|
-
|
|
2541
|
-
/**
|
|
2542
|
-
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2543
|
-
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2544
|
-
* `page` methods.
|
|
2545
|
-
*
|
|
2546
|
-
* Setting the value to `0` will disable the timeout.
|
|
2547
|
-
*/
|
|
2548
|
-
timeout?: number;
|
|
2549
|
-
},
|
|
2550
|
-
): boolean;
|
|
2604
|
+
isHidden(selector: string, options?: StrictnessOptions): boolean;
|
|
2551
2605
|
|
|
2552
2606
|
/**
|
|
2553
|
-
* **NOTE** Use locator-based locator.isVisible(
|
|
2607
|
+
* **NOTE** Use locator-based locator.isVisible() instead.
|
|
2554
2608
|
*
|
|
2555
2609
|
* Returns whether the element is visible.
|
|
2556
2610
|
*
|
|
@@ -2558,26 +2612,7 @@ export interface Page {
|
|
|
2558
2612
|
* elements satisfying the selector, the first will be used.
|
|
2559
2613
|
* @param options
|
|
2560
2614
|
*/
|
|
2561
|
-
isVisible(
|
|
2562
|
-
selector: string,
|
|
2563
|
-
options?: {
|
|
2564
|
-
/**
|
|
2565
|
-
* When `true`, the call requires selector to resolve to a single element.
|
|
2566
|
-
* If given selector resolves to more than one element, the call throws
|
|
2567
|
-
* an exception. Defaults to `false`.
|
|
2568
|
-
*/
|
|
2569
|
-
strict?: boolean;
|
|
2570
|
-
|
|
2571
|
-
/**
|
|
2572
|
-
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2573
|
-
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2574
|
-
* `page` methods.
|
|
2575
|
-
*
|
|
2576
|
-
* Setting the value to `0` will disable the timeout.
|
|
2577
|
-
*/
|
|
2578
|
-
timeout?: number;
|
|
2579
|
-
},
|
|
2580
|
-
): boolean;
|
|
2615
|
+
isVisible(selector: string, options?: StrictnessOptions): boolean;
|
|
2581
2616
|
|
|
2582
2617
|
/**
|
|
2583
2618
|
* Returns the keyboard instance to interact with a virtual keyboard on the
|
|
@@ -2992,6 +3027,55 @@ export interface Page {
|
|
|
2992
3027
|
},
|
|
2993
3028
|
): string;
|
|
2994
3029
|
|
|
3030
|
+
/**
|
|
3031
|
+
* Throttles the CPU in Chrome/Chromium to slow it down by the specified
|
|
3032
|
+
* `rate` in {@link CPUProfile}. {@link CPUProfile} is a mandatory
|
|
3033
|
+
* input argument. The default `rate` is `1`.
|
|
3034
|
+
*
|
|
3035
|
+
* **Usage**
|
|
3036
|
+
*
|
|
3037
|
+
* ```js
|
|
3038
|
+
* page.throttleCPU({ rate: 4 });
|
|
3039
|
+
* ```
|
|
3040
|
+
*/
|
|
3041
|
+
throttleCPU(profile: CPUProfile): void;
|
|
3042
|
+
|
|
3043
|
+
/**
|
|
3044
|
+
* Throttles the network in Chrome/Chromium to slow it down by the specified
|
|
3045
|
+
* fields in {@link NetworkProfile}. {@link NetworkProfile} is a mandatory
|
|
3046
|
+
* input argument.
|
|
3047
|
+
*
|
|
3048
|
+
* **Usage**
|
|
3049
|
+
*
|
|
3050
|
+
* ```js
|
|
3051
|
+
* page.throttleNetwork({
|
|
3052
|
+
* latency: 750,
|
|
3053
|
+
* download: 250,
|
|
3054
|
+
* upload: 250,
|
|
3055
|
+
* });
|
|
3056
|
+
* ```
|
|
3057
|
+
*
|
|
3058
|
+
* To work with the most commonly tested network profiles, import `networkProfiles`
|
|
3059
|
+
* from the browser module. There are three profiles available:
|
|
3060
|
+
* - `'No Throttling'` (default)
|
|
3061
|
+
* - `'Fast 3G'`
|
|
3062
|
+
* - `'Slow 3G'`
|
|
3063
|
+
*
|
|
3064
|
+
* **Usage**
|
|
3065
|
+
*
|
|
3066
|
+
* ```js
|
|
3067
|
+
* import { browser, networkProfiles } from 'k6/experimental/browser';
|
|
3068
|
+
* ... // redacted
|
|
3069
|
+
* const context = browser.newContext();
|
|
3070
|
+
* const page = context.newPage();
|
|
3071
|
+
*
|
|
3072
|
+
* try {
|
|
3073
|
+
* page.throttleNetwork(networkProfiles['Slow 3G']);
|
|
3074
|
+
* ... // redacted
|
|
3075
|
+
* ```
|
|
3076
|
+
*/
|
|
3077
|
+
throttleNetwork(profile: NetworkProfile): void;
|
|
3078
|
+
|
|
2995
3079
|
/**
|
|
2996
3080
|
* Returns the page's title.
|
|
2997
3081
|
*/
|
k6/experimental/fs.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The k6 experimental filesystem module provides an API for handling file operations
|
|
3
|
+
* in your k6 tests. It allows you to read files within your test scripts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Opens a file and returns a promise that resolves to an instance of the `File` class.
|
|
8
|
+
*
|
|
9
|
+
* Note: As the k6 init context doesn't support 'await', use the following pattern:
|
|
10
|
+
*
|
|
11
|
+
* Example:
|
|
12
|
+
* ```
|
|
13
|
+
* let fileHandle;
|
|
14
|
+
* (async function() {
|
|
15
|
+
* fileHandle = await open("example.txt");
|
|
16
|
+
* }());
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param path - The file path as a string. Relative paths are resolved relative to the k6 script.
|
|
20
|
+
* @returns Promise<File> - A promise that resolves to a `File` instance.
|
|
21
|
+
*/
|
|
22
|
+
export function open(path: string): Promise<File>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents a file and provides methods to interact with file data.
|
|
26
|
+
* This class offers read-only access to file contents.
|
|
27
|
+
*/
|
|
28
|
+
export class File {
|
|
29
|
+
/**
|
|
30
|
+
* The absolute path of the file.
|
|
31
|
+
*
|
|
32
|
+
* This is resolved relative to the k6 script.
|
|
33
|
+
*/
|
|
34
|
+
path: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Reads the file into a specified buffer type and returns the number of bytes read.
|
|
38
|
+
* Resolves to `null` if there's nothing to read (EOF or empty file).
|
|
39
|
+
*
|
|
40
|
+
* Example:
|
|
41
|
+
* ```
|
|
42
|
+
* const buffer = new Uint8Array(100);
|
|
43
|
+
* const bytesRead = await file.read(buffer);
|
|
44
|
+
* console.log(`Read ${bytesRead} bytes`);
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param p - A Uint8Array buffer to read the file into.
|
|
48
|
+
* @returns Promise<number> - Number of bytes read or `null`.
|
|
49
|
+
*/
|
|
50
|
+
read(p: Uint8Array): Promise<number>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Moves the file pointer to a new location, based on `offset` and `whence`.
|
|
54
|
+
* Resolves to the new position within the file (in bytes).
|
|
55
|
+
*
|
|
56
|
+
* When using `SeekMode.Start`, the offset must be greater than or equal to zero.
|
|
57
|
+
* When using `SeekMode.Current`, the offset can be positive or negative.
|
|
58
|
+
* When using `SeekMode.End`, the offset must be less than or equal to zero.
|
|
59
|
+
*
|
|
60
|
+
* Example:
|
|
61
|
+
* ```
|
|
62
|
+
* const newOffset = await file.seek(10, SeekMode.Start);
|
|
63
|
+
* console.log(`Pointer moved to position ${newOffset}`);
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param offset - The offset to seek to.
|
|
67
|
+
* @param whence - The position from where offset is added (Start, Current, or End).
|
|
68
|
+
* @returns Promise<number> - The new position in the file.
|
|
69
|
+
*/
|
|
70
|
+
seek(offset: number, whence: SeekMode): Promise<number>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves information about the file.
|
|
74
|
+
* Resolves to a `FileInfo` object describing the file.
|
|
75
|
+
*
|
|
76
|
+
* Example:
|
|
77
|
+
* ```
|
|
78
|
+
* const fileInfo = await file.stat();
|
|
79
|
+
* console.log(`File size: ${fileInfo.size} bytes`);
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @returns Promise<FileInfo> - Information about the file.
|
|
83
|
+
*/
|
|
84
|
+
stat(): Promise<FileInfo>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Contains information about a file, including its name and size.
|
|
89
|
+
*/
|
|
90
|
+
export interface FileInfo {
|
|
91
|
+
name: string; // The name of the file
|
|
92
|
+
size: number; // The size of the file in bytes
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Enumeration for file seek modes.
|
|
97
|
+
*/
|
|
98
|
+
export enum SeekMode {
|
|
99
|
+
Start = 0, // Seek from the start of the file
|
|
100
|
+
Current = 1, // Seek from the current file position.
|
|
101
|
+
End = 2, // Seek from the end of the file
|
|
102
|
+
}
|
k6/experimental/grpc.d.ts
CHANGED
|
@@ -97,12 +97,16 @@ export interface GrpcError {
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* This module provides classes for Remote Procedure Calls over HTTP/2.
|
|
100
|
-
* https://
|
|
100
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/grpc/
|
|
101
|
+
*
|
|
102
|
+
* @deprecated Use the `k6/net/grpc` module instead.
|
|
101
103
|
*/
|
|
102
104
|
declare namespace grpc {
|
|
103
105
|
/**
|
|
104
106
|
* gRPC client to interact with a gRPC server.
|
|
105
|
-
* https://
|
|
107
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/grpc/client/
|
|
108
|
+
*
|
|
109
|
+
* @deprecated Use the `k6/net/grpc` module instead.
|
|
106
110
|
*/
|
|
107
111
|
class Client {
|
|
108
112
|
protected __brand: never;
|
|
@@ -145,6 +149,8 @@ declare namespace grpc {
|
|
|
145
149
|
|
|
146
150
|
/**
|
|
147
151
|
* Stream allows you to use streaming RPCs.
|
|
152
|
+
*
|
|
153
|
+
* @deprecated Use the `k6/net/grpc` module instead.
|
|
148
154
|
*/
|
|
149
155
|
class Stream {
|
|
150
156
|
/**
|