codeceptjs 3.6.0-beta.1.ai-healers → 3.6.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.
Files changed (129) hide show
  1. package/README.md +2 -2
  2. package/bin/codecept.js +2 -1
  3. package/docs/webapi/dontSeeTraffic.mustache +13 -0
  4. package/docs/webapi/flushNetworkTraffics.mustache +5 -0
  5. package/docs/webapi/grabRecordedNetworkTraffics.mustache +10 -0
  6. package/docs/webapi/seeTraffic.mustache +36 -0
  7. package/docs/webapi/startRecordingTraffic.mustache +8 -0
  8. package/docs/webapi/startRecordingWebSocketMessages.mustache +8 -0
  9. package/docs/webapi/stopRecordingTraffic.mustache +5 -0
  10. package/docs/webapi/stopRecordingWebSocketMessages.mustache +7 -0
  11. package/docs/webapi/waitForCookie.mustache +9 -0
  12. package/lib/actor.js +6 -3
  13. package/lib/command/dryRun.js +44 -13
  14. package/lib/helper/Appium.js +36 -12
  15. package/lib/helper/Expect.js +11 -8
  16. package/lib/helper/JSONResponse.js +8 -8
  17. package/lib/helper/MockServer.js +221 -0
  18. package/lib/helper/Playwright.js +107 -371
  19. package/lib/helper/Puppeteer.js +404 -71
  20. package/lib/helper/REST.js +4 -1
  21. package/lib/helper/WebDriver.js +189 -13
  22. package/lib/helper/errors/ElementAssertion.js +38 -0
  23. package/lib/helper/extras/PlaywrightReactVueLocator.js +6 -1
  24. package/lib/helper/network/actions.js +123 -0
  25. package/lib/helper/network/utils.js +187 -0
  26. package/lib/locator.js +36 -5
  27. package/lib/plugin/coverage.js +112 -99
  28. package/lib/step.js +3 -1
  29. package/package.json +48 -37
  30. package/typings/index.d.ts +19 -2
  31. package/typings/promiseBasedTypes.d.ts +505 -41
  32. package/typings/types.d.ts +609 -56
  33. package/docs/advanced.md +0 -351
  34. package/docs/ai.md +0 -365
  35. package/docs/api.md +0 -323
  36. package/docs/basics.md +0 -979
  37. package/docs/bdd.md +0 -539
  38. package/docs/best.md +0 -237
  39. package/docs/books.md +0 -37
  40. package/docs/bootstrap.md +0 -135
  41. package/docs/build/AI.js +0 -124
  42. package/docs/build/ApiDataFactory.js +0 -410
  43. package/docs/build/Appium.js +0 -2027
  44. package/docs/build/Expect.js +0 -422
  45. package/docs/build/FileSystem.js +0 -228
  46. package/docs/build/GraphQL.js +0 -229
  47. package/docs/build/GraphQLDataFactory.js +0 -309
  48. package/docs/build/JSONResponse.js +0 -338
  49. package/docs/build/Mochawesome.js +0 -71
  50. package/docs/build/Nightmare.js +0 -2152
  51. package/docs/build/OpenAI.js +0 -126
  52. package/docs/build/Playwright.js +0 -5110
  53. package/docs/build/Protractor.js +0 -2706
  54. package/docs/build/Puppeteer.js +0 -3905
  55. package/docs/build/REST.js +0 -344
  56. package/docs/build/TestCafe.js +0 -2125
  57. package/docs/build/WebDriver.js +0 -4240
  58. package/docs/changelog.md +0 -2572
  59. package/docs/commands.md +0 -266
  60. package/docs/community-helpers.md +0 -58
  61. package/docs/configuration.md +0 -157
  62. package/docs/continuous-integration.md +0 -22
  63. package/docs/custom-helpers.md +0 -306
  64. package/docs/data.md +0 -379
  65. package/docs/detox.md +0 -235
  66. package/docs/docker.md +0 -136
  67. package/docs/email.md +0 -183
  68. package/docs/examples.md +0 -149
  69. package/docs/heal.md +0 -186
  70. package/docs/helpers/ApiDataFactory.md +0 -266
  71. package/docs/helpers/Appium.md +0 -1374
  72. package/docs/helpers/Detox.md +0 -586
  73. package/docs/helpers/Expect.md +0 -275
  74. package/docs/helpers/FileSystem.md +0 -152
  75. package/docs/helpers/GraphQL.md +0 -151
  76. package/docs/helpers/GraphQLDataFactory.md +0 -226
  77. package/docs/helpers/JSONResponse.md +0 -254
  78. package/docs/helpers/Mochawesome.md +0 -8
  79. package/docs/helpers/MockRequest.md +0 -377
  80. package/docs/helpers/Nightmare.md +0 -1305
  81. package/docs/helpers/OpenAI.md +0 -70
  82. package/docs/helpers/Playwright.md +0 -2759
  83. package/docs/helpers/Polly.md +0 -44
  84. package/docs/helpers/Protractor.md +0 -1769
  85. package/docs/helpers/Puppeteer-firefox.md +0 -86
  86. package/docs/helpers/Puppeteer.md +0 -2317
  87. package/docs/helpers/REST.md +0 -218
  88. package/docs/helpers/TestCafe.md +0 -1321
  89. package/docs/helpers/WebDriver.md +0 -2547
  90. package/docs/hooks.md +0 -340
  91. package/docs/index.md +0 -111
  92. package/docs/installation.md +0 -75
  93. package/docs/internal-api.md +0 -266
  94. package/docs/locators.md +0 -339
  95. package/docs/mobile-react-native-locators.md +0 -67
  96. package/docs/mobile.md +0 -338
  97. package/docs/pageobjects.md +0 -291
  98. package/docs/parallel.md +0 -400
  99. package/docs/playwright.md +0 -632
  100. package/docs/plugins.md +0 -1247
  101. package/docs/puppeteer.md +0 -316
  102. package/docs/quickstart.md +0 -162
  103. package/docs/react.md +0 -70
  104. package/docs/reports.md +0 -392
  105. package/docs/secrets.md +0 -36
  106. package/docs/shadow.md +0 -68
  107. package/docs/shared/keys.mustache +0 -31
  108. package/docs/shared/react.mustache +0 -1
  109. package/docs/testcafe.md +0 -174
  110. package/docs/translation.md +0 -247
  111. package/docs/tutorial.md +0 -271
  112. package/docs/typescript.md +0 -180
  113. package/docs/ui.md +0 -59
  114. package/docs/videos.md +0 -28
  115. package/docs/visual.md +0 -202
  116. package/docs/vue.md +0 -143
  117. package/docs/webdriver.md +0 -701
  118. package/docs/wiki/Books-&-Posts.md +0 -27
  119. package/docs/wiki/Community-Helpers-&-Plugins.md +0 -53
  120. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -61
  121. package/docs/wiki/Examples.md +0 -145
  122. package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
  123. package/docs/wiki/Home.md +0 -16
  124. package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +0 -83
  125. package/docs/wiki/Release-Process.md +0 -24
  126. package/docs/wiki/Roadmap.md +0 -23
  127. package/docs/wiki/Tests.md +0 -1393
  128. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -153
  129. package/docs/wiki/Videos.md +0 -19
@@ -1191,9 +1191,9 @@ declare namespace CodeceptJS {
1191
1191
  expectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg?: any): void;
1192
1192
  expectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg?: any): void;
1193
1193
  /**
1194
- * @param ajvOptions - Pass AJV options
1194
+ * @param [ajvOptions] - Pass AJV options
1195
1195
  */
1196
- expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: any, ajvOptions: any): void;
1196
+ expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: any, ajvOptions?: any): void;
1197
1197
  expectHasProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
1198
1198
  expectHasAProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
1199
1199
  expectToBeA(targetData: any, type: any, customErrorMsg?: any): void;
@@ -1799,6 +1799,191 @@ declare namespace CodeceptJS {
1799
1799
  */
1800
1800
  seeResponseMatchesJsonSchema(fnOrSchema: any): void;
1801
1801
  }
1802
+ /**
1803
+ * ## Configuration
1804
+ *
1805
+ * This helper should be configured in codecept.conf.(js|ts)
1806
+ * @property [port = 9393] - Mock server port
1807
+ * @property [host = "0.0.0.0"] - Mock server host
1808
+ * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
1809
+ */
1810
+ type MockServerConfig = {
1811
+ port?: number;
1812
+ host?: string;
1813
+ httpsOpts?: any;
1814
+ };
1815
+ /**
1816
+ * MockServer
1817
+ *
1818
+ * The MockServer Helper in CodeceptJS empowers you to mock any server or service via HTTP or HTTPS, making it an excellent tool for simulating REST endpoints and other HTTP-based APIs.
1819
+ *
1820
+ * <!-- configuration -->
1821
+ *
1822
+ * #### Examples
1823
+ *
1824
+ * You can seamlessly integrate MockServer with other helpers like REST or Playwright. Here's a configuration example inside the `codecept.conf.js` file:
1825
+ *
1826
+ * ```javascript
1827
+ * {
1828
+ * helpers: {
1829
+ * REST: {...},
1830
+ * MockServer: {
1831
+ * // default mock server config
1832
+ * port: 9393,
1833
+ * host: '0.0.0.0',
1834
+ * httpsOpts: {
1835
+ * key: '',
1836
+ * cert: '',
1837
+ * },
1838
+ * },
1839
+ * }
1840
+ * }
1841
+ * ```
1842
+ *
1843
+ * #### Adding Interactions
1844
+ *
1845
+ * Interactions add behavior to the mock server. Use the `I.addInteractionToMockServer()` method to include interactions. It takes an interaction object as an argument, containing request and response details.
1846
+ *
1847
+ * ```javascript
1848
+ * I.addInteractionToMockServer({
1849
+ * request: {
1850
+ * method: 'GET',
1851
+ * path: '/api/hello'
1852
+ * },
1853
+ * response: {
1854
+ * status: 200,
1855
+ * body: {
1856
+ * 'say': 'hello to mock server'
1857
+ * }
1858
+ * }
1859
+ * });
1860
+ * ```
1861
+ *
1862
+ * #### Request Matching
1863
+ *
1864
+ * When a real request is sent to the mock server, it matches the received request with the interactions. If a match is found, it returns the specified response; otherwise, a 404 status code is returned.
1865
+ *
1866
+ * - Strong match on HTTP Method, Path, Query Params & JSON body.
1867
+ * - Loose match on Headers.
1868
+ *
1869
+ * ##### Strong Match on Query Params
1870
+ *
1871
+ * You can send different responses based on query parameters:
1872
+ *
1873
+ * ```javascript
1874
+ * I.addInteractionToMockServer({
1875
+ * request: {
1876
+ * method: 'GET',
1877
+ * path: '/api/users',
1878
+ * queryParams: {
1879
+ * id: 1
1880
+ * }
1881
+ * },
1882
+ * response: {
1883
+ * status: 200,
1884
+ * body: 'user 1'
1885
+ * }
1886
+ * });
1887
+ *
1888
+ * I.addInteractionToMockServer({
1889
+ * request: {
1890
+ * method: 'GET',
1891
+ * path: '/api/users',
1892
+ * queryParams: {
1893
+ * id: 2
1894
+ * }
1895
+ * },
1896
+ * response: {
1897
+ * status: 200,
1898
+ * body: 'user 2'
1899
+ * }
1900
+ * });
1901
+ * ```
1902
+ *
1903
+ * - GET to `/api/users?id=1` will return 'user 1'.
1904
+ * - GET to `/api/users?id=2` will return 'user 2'.
1905
+ * - For all other requests, it returns a 404 status code.
1906
+ *
1907
+ * ##### Loose Match on Body
1908
+ *
1909
+ * When `strict` is set to false, it performs a loose match on query params and response body:
1910
+ *
1911
+ * ```javascript
1912
+ * I.addInteractionToMockServer({
1913
+ * strict: false,
1914
+ * request: {
1915
+ * method: 'POST',
1916
+ * path: '/api/users',
1917
+ * body: {
1918
+ * name: 'john'
1919
+ * }
1920
+ * },
1921
+ * response: {
1922
+ * status: 200
1923
+ * }
1924
+ * });
1925
+ * ```
1926
+ *
1927
+ * - POST to `/api/users` with the body containing `name` as 'john' will return a 200 status code.
1928
+ * - POST to `/api/users` without the `name` property in the body will return a 404 status code.
1929
+ *
1930
+ * Happy testing with MockServer in CodeceptJS! 🚀
1931
+ *
1932
+ * ## Methods
1933
+ */
1934
+ class MockServer {
1935
+ /**
1936
+ * Start the mock server
1937
+ * @param [port] - start the mock server with given port
1938
+ * @returns void
1939
+ */
1940
+ startMockServer(port?: number): any;
1941
+ /**
1942
+ * Stop the mock server
1943
+ * @returns void
1944
+ */
1945
+ stopMockServer(): any;
1946
+ /**
1947
+ * An interaction adds behavior to the mock server
1948
+ *
1949
+ *
1950
+ * ```js
1951
+ * I.addInteractionToMockServer({
1952
+ * request: {
1953
+ * method: 'GET',
1954
+ * path: '/api/hello'
1955
+ * },
1956
+ * response: {
1957
+ * status: 200,
1958
+ * body: {
1959
+ * 'say': 'hello to mock server'
1960
+ * }
1961
+ * }
1962
+ * });
1963
+ * ```
1964
+ * ```js
1965
+ * // with query params
1966
+ * I.addInteractionToMockServer({
1967
+ * request: {
1968
+ * method: 'GET',
1969
+ * path: '/api/hello',
1970
+ * queryParams: {
1971
+ * id: 2
1972
+ * }
1973
+ * },
1974
+ * response: {
1975
+ * status: 200,
1976
+ * body: {
1977
+ * 'say': 'hello to mock server'
1978
+ * }
1979
+ * }
1980
+ * });
1981
+ * ```
1982
+ * @param interaction - add behavior to the mock server
1983
+ * @returns void
1984
+ */
1985
+ addInteractionToMockServer(interaction: CodeceptJS.MockInteraction | any): any;
1986
+ }
1802
1987
  /**
1803
1988
  * Nightmare helper wraps [Nightmare](https://github.com/segmentio/nightmare) library to provide
1804
1989
  * fastest headless testing using Electron engine. Unlike Selenium-based drivers this uses
@@ -2883,6 +3068,7 @@ declare namespace CodeceptJS {
2883
3068
  * @property [bypassCSP] - bypass Content Security Policy or CSP
2884
3069
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
2885
3070
  * @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
3071
+ * @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
2886
3072
  */
2887
3073
  type PlaywrightConfig = {
2888
3074
  url?: string;
@@ -2920,6 +3106,7 @@ declare namespace CodeceptJS {
2920
3106
  bypassCSP?: boolean;
2921
3107
  highlightElement?: boolean;
2922
3108
  recordHar?: any;
3109
+ testIdAttribute?: string;
2923
3110
  };
2924
3111
  /**
2925
3112
  * Uses [Playwright](https://github.com/microsoft/playwright) library to run tests inside:
@@ -4747,6 +4934,17 @@ declare namespace CodeceptJS {
4747
4934
  * @returns automatically synchronized promise through #recorder
4748
4935
  */
4749
4936
  waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): void;
4937
+ /**
4938
+ * Waits for the specified cookie in the cookies.
4939
+ *
4940
+ * ```js
4941
+ * I.waitForCookie("token");
4942
+ * ```
4943
+ * @param name - expected cookie name.
4944
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
4945
+ * @returns automatically synchronized promise through #recorder
4946
+ */
4947
+ waitForCookie(name: string, sec?: number): void;
4750
4948
  /**
4751
4949
  * Grab the data from performance timing using Navigation Timing API.
4752
4950
  * The returned data will contain following things in ms:
@@ -4801,7 +4999,7 @@ declare namespace CodeceptJS {
4801
4999
  * ```
4802
5000
  * This method allows intercepting and mocking requests & responses. [Learn more about it](https://playwright.dev/docs/network#handle-requests)
4803
5001
  * @param [url] - URL, regex or pattern for to match URL
4804
- * @param [handler] - a function to process reques
5002
+ * @param [handler] - a function to process request
4805
5003
  */
4806
5004
  mockRoute(url?: string | RegExp, handler?: (...params: any[]) => any): void;
4807
5005
  /**
@@ -4813,29 +5011,17 @@ declare namespace CodeceptJS {
4813
5011
  * ```
4814
5012
  * If no handler is passed, all mock requests for the rote are disabled.
4815
5013
  * @param [url] - URL, regex or pattern for to match URL
4816
- * @param [handler] - a function to process reques
5014
+ * @param [handler] - a function to process request
4817
5015
  */
4818
5016
  stopMockingRoute(url?: string | RegExp, handler?: (...params: any[]) => any): void;
4819
5017
  /**
4820
- * Starts recording the network traffics.
4821
- * This also resets recorded network requests.
5018
+ * Resets all recorded network requests.
4822
5019
  *
4823
5020
  * ```js
4824
- * I.startRecordingTraffic();
5021
+ * I.flushNetworkTraffics();
4825
5022
  * ```
4826
5023
  */
4827
5024
  startRecordingTraffic(): void;
4828
- /**
4829
- * Grab the recording network traffics
4830
- *
4831
- * ```js
4832
- * const traffics = await I.grabRecordedNetworkTraffics();
4833
- * expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
4834
- * expect(traffics[0].response.status).to.equal(200);
4835
- * expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
4836
- * ```
4837
- */
4838
- grabRecordedNetworkTraffics(): Promise<any[]>;
4839
5025
  /**
4840
5026
  * Blocks traffic of a given URL or a list of URLs.
4841
5027
  *
@@ -4872,6 +5058,10 @@ declare namespace CodeceptJS {
4872
5058
  mockTraffic(urls: any, responseString: any, contentType?: any): void;
4873
5059
  /**
4874
5060
  * Resets all recorded network requests.
5061
+ *
5062
+ * ```js
5063
+ * I.flushNetworkTraffics();
5064
+ * ```
4875
5065
  */
4876
5066
  flushNetworkTraffics(): void;
4877
5067
  /**
@@ -4882,6 +5072,30 @@ declare namespace CodeceptJS {
4882
5072
  * ```
4883
5073
  */
4884
5074
  stopRecordingTraffic(): void;
5075
+ /**
5076
+ * Returns full URL of request matching parameter "urlMatch".
5077
+ * @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
5078
+ *
5079
+ * Examples:
5080
+ *
5081
+ * ```js
5082
+ * I.grabTrafficUrl('https://api.example.com/session');
5083
+ * I.grabTrafficUrl(/session.*start/);
5084
+ * ```
5085
+ */
5086
+ grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
5087
+ /**
5088
+ * Grab the recording network traffics
5089
+ *
5090
+ * ```js
5091
+ * const traffics = await I.grabRecordedNetworkTraffics();
5092
+ * expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
5093
+ * expect(traffics[0].response.status).to.equal(200);
5094
+ * expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
5095
+ * ```
5096
+ * @returns recorded network traffics
5097
+ */
5098
+ grabRecordedNetworkTraffics(): any[];
4885
5099
  /**
4886
5100
  * Verifies that a certain request is part of network traffic.
4887
5101
  *
@@ -4890,13 +5104,13 @@ declare namespace CodeceptJS {
4890
5104
  * I.amOnPage('https://openai.com/blog/chatgpt');
4891
5105
  * I.startRecordingTraffic();
4892
5106
  * await I.seeTraffic({
4893
- * name: 'sentry event',
4894
- * url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
4895
- * parameters: {
4896
- * width: '1919',
4897
- * height: '1138',
5107
+ * name: 'sentry event',
5108
+ * url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
5109
+ * parameters: {
5110
+ * width: '1919',
5111
+ * height: '1138',
4898
5112
  * },
4899
- * });
5113
+ * });
4900
5114
  * ```
4901
5115
  *
4902
5116
  * ```js
@@ -4904,12 +5118,12 @@ declare namespace CodeceptJS {
4904
5118
  * I.amOnPage('https://openai.com/blog/chatgpt');
4905
5119
  * I.startRecordingTraffic();
4906
5120
  * await I.seeTraffic({
4907
- * name: 'event',
4908
- * url: 'https://cloudflareinsights.com/cdn-cgi/rum',
4909
- * requestPostData: {
4910
- * st: 2,
5121
+ * name: 'event',
5122
+ * url: 'https://cloudflareinsights.com/cdn-cgi/rum',
5123
+ * requestPostData: {
5124
+ * st: 2,
4911
5125
  * },
4912
- * });
5126
+ * });
4913
5127
  * ```
4914
5128
  * @param opts - options when checking the traffic network.
4915
5129
  * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
@@ -4917,6 +5131,7 @@ declare namespace CodeceptJS {
4917
5131
  * @param [opts.parameters] - Expected parameters of that request in network traffic
4918
5132
  * @param [opts.requestPostData] - Expected that request contains post data in network traffic
4919
5133
  * @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
5134
+ * @returns automatically synchronized promise through #recorder
4920
5135
  */
4921
5136
  seeTraffic(opts: {
4922
5137
  name: string;
@@ -4924,19 +5139,7 @@ declare namespace CodeceptJS {
4924
5139
  parameters?: any;
4925
5140
  requestPostData?: any;
4926
5141
  timeout?: number;
4927
- }): Promise<any>;
4928
- /**
4929
- * Returns full URL of request matching parameter "urlMatch".
4930
- * @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
4931
- *
4932
- * Examples:
4933
- *
4934
- * ```js
4935
- * I.grabTrafficUrl('https://api.example.com/session');
4936
- * I.grabTrafficUrl(/session.*start/);
4937
- * ```
4938
- */
4939
- grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
5142
+ }): void;
4940
5143
  /**
4941
5144
  * Verifies that a certain request is not part of network traffic.
4942
5145
  *
@@ -4949,6 +5152,7 @@ declare namespace CodeceptJS {
4949
5152
  * @param opts - options when checking the traffic network.
4950
5153
  * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
4951
5154
  * @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
5155
+ * @returns automatically synchronized promise through #recorder
4952
5156
  */
4953
5157
  dontSeeTraffic(opts: {
4954
5158
  name: string;
@@ -4961,6 +5165,7 @@ declare namespace CodeceptJS {
4961
5165
  * ```js
4962
5166
  * await I.startRecordingWebSocketMessages();
4963
5167
  * ```
5168
+ * @returns automatically synchronized promise through #recorder
4964
5169
  */
4965
5170
  startRecordingWebSocketMessages(): void;
4966
5171
  /**
@@ -4969,6 +5174,7 @@ declare namespace CodeceptJS {
4969
5174
  * ```js
4970
5175
  * await I.stopRecordingWebSocketMessages();
4971
5176
  * ```
5177
+ * @returns automatically synchronized promise through #recorder
4972
5178
  */
4973
5179
  stopRecordingWebSocketMessages(): void;
4974
5180
  /**
@@ -7612,6 +7818,17 @@ declare namespace CodeceptJS {
7612
7818
  * Returns cookie in JSON format. If name not passed returns all cookies for this domain.
7613
7819
  */
7614
7820
  grabCookie(name?: string): any;
7821
+ /**
7822
+ * Waits for the specified cookie in the cookies.
7823
+ *
7824
+ * ```js
7825
+ * I.waitForCookie("token");
7826
+ * ```
7827
+ * @param name - expected cookie name.
7828
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
7829
+ * @returns automatically synchronized promise through #recorder
7830
+ */
7831
+ waitForCookie(name: string, sec?: number): void;
7615
7832
  /**
7616
7833
  * Clears a cookie by name,
7617
7834
  * if none provided clears all cookies.
@@ -8152,6 +8369,153 @@ declare namespace CodeceptJS {
8152
8369
  * @returns Element bounding rectangle
8153
8370
  */
8154
8371
  grabElementBoundingRect(locator: LocatorOrString, elementSize?: string): Promise<DOMRect> | Promise<number>;
8372
+ /**
8373
+ * Mocks network request using [`Request Interception`](https://pptr.dev/next/guides/request-interception)
8374
+ *
8375
+ * ```js
8376
+ * I.mockRoute(/(\.png$)|(\.jpg$)/, route => route.abort());
8377
+ * ```
8378
+ * This method allows intercepting and mocking requests & responses. [Learn more about it](https://pptr.dev/next/guides/request-interception)
8379
+ * @param [url] - URL, regex or pattern for to match URL
8380
+ * @param [handler] - a function to process request
8381
+ */
8382
+ mockRoute(url?: string | RegExp, handler?: (...params: any[]) => any): void;
8383
+ /**
8384
+ * Stops network mocking created by `mockRoute`.
8385
+ *
8386
+ * ```js
8387
+ * I.stopMockingRoute(/(\.png$)|(\.jpg$)/);
8388
+ * ```
8389
+ * @param [url] - URL, regex or pattern for to match URL
8390
+ */
8391
+ stopMockingRoute(url?: string | RegExp): void;
8392
+ /**
8393
+ * Resets all recorded network requests.
8394
+ *
8395
+ * ```js
8396
+ * I.flushNetworkTraffics();
8397
+ * ```
8398
+ */
8399
+ flushNetworkTraffics(): void;
8400
+ /**
8401
+ * Stops recording of network traffic. Recorded traffic is not flashed.
8402
+ *
8403
+ * ```js
8404
+ * I.stopRecordingTraffic();
8405
+ * ```
8406
+ */
8407
+ stopRecordingTraffic(): void;
8408
+ /**
8409
+ * Starts recording the network traffics.
8410
+ * This also resets recorded network requests.
8411
+ *
8412
+ * ```js
8413
+ * I.startRecordingTraffic();
8414
+ * ```
8415
+ * @returns automatically synchronized promise through #recorder
8416
+ */
8417
+ startRecordingTraffic(): void;
8418
+ /**
8419
+ * Grab the recording network traffics
8420
+ *
8421
+ * ```js
8422
+ * const traffics = await I.grabRecordedNetworkTraffics();
8423
+ * expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
8424
+ * expect(traffics[0].response.status).to.equal(200);
8425
+ * expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
8426
+ * ```
8427
+ * @returns recorded network traffics
8428
+ */
8429
+ grabRecordedNetworkTraffics(): any[];
8430
+ /**
8431
+ * Verifies that a certain request is part of network traffic.
8432
+ *
8433
+ * ```js
8434
+ * // checking the request url contains certain query strings
8435
+ * I.amOnPage('https://openai.com/blog/chatgpt');
8436
+ * I.startRecordingTraffic();
8437
+ * await I.seeTraffic({
8438
+ * name: 'sentry event',
8439
+ * url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
8440
+ * parameters: {
8441
+ * width: '1919',
8442
+ * height: '1138',
8443
+ * },
8444
+ * });
8445
+ * ```
8446
+ *
8447
+ * ```js
8448
+ * // checking the request url contains certain post data
8449
+ * I.amOnPage('https://openai.com/blog/chatgpt');
8450
+ * I.startRecordingTraffic();
8451
+ * await I.seeTraffic({
8452
+ * name: 'event',
8453
+ * url: 'https://cloudflareinsights.com/cdn-cgi/rum',
8454
+ * requestPostData: {
8455
+ * st: 2,
8456
+ * },
8457
+ * });
8458
+ * ```
8459
+ * @param opts - options when checking the traffic network.
8460
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
8461
+ * @param opts.url - Expected URL of request in network traffic
8462
+ * @param [opts.parameters] - Expected parameters of that request in network traffic
8463
+ * @param [opts.requestPostData] - Expected that request contains post data in network traffic
8464
+ * @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
8465
+ * @returns automatically synchronized promise through #recorder
8466
+ */
8467
+ seeTraffic(opts: {
8468
+ name: string;
8469
+ url: string;
8470
+ parameters?: any;
8471
+ requestPostData?: any;
8472
+ timeout?: number;
8473
+ }): void;
8474
+ /**
8475
+ * Verifies that a certain request is not part of network traffic.
8476
+ *
8477
+ * Examples:
8478
+ *
8479
+ * ```js
8480
+ * I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
8481
+ * I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
8482
+ * ```
8483
+ * @param opts - options when checking the traffic network.
8484
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
8485
+ * @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
8486
+ * @returns automatically synchronized promise through #recorder
8487
+ */
8488
+ dontSeeTraffic(opts: {
8489
+ name: string;
8490
+ url: string | RegExp;
8491
+ }): void;
8492
+ /**
8493
+ * Starts recording of websocket messages.
8494
+ * This also resets recorded websocket messages.
8495
+ *
8496
+ * ```js
8497
+ * await I.startRecordingWebSocketMessages();
8498
+ * ```
8499
+ * @returns automatically synchronized promise through #recorder
8500
+ */
8501
+ startRecordingWebSocketMessages(): void;
8502
+ /**
8503
+ * Stops recording WS messages. Recorded WS messages is not flashed.
8504
+ *
8505
+ * ```js
8506
+ * await I.stopRecordingWebSocketMessages();
8507
+ * ```
8508
+ * @returns automatically synchronized promise through #recorder
8509
+ */
8510
+ stopRecordingWebSocketMessages(): void;
8511
+ /**
8512
+ * Grab the recording WS messages
8513
+ */
8514
+ grabWebSocketMessages(): any[] | undefined;
8515
+ /**
8516
+ * Resets all recorded WS messages.
8517
+ */
8518
+ flushWebSocketMessages(): void;
8155
8519
  }
8156
8520
  /**
8157
8521
  * ## Configuration
@@ -10707,6 +11071,17 @@ declare namespace CodeceptJS {
10707
11071
  * @returns attribute value
10708
11072
  */
10709
11073
  grabCookie(name?: string): any;
11074
+ /**
11075
+ * Waits for the specified cookie in the cookies.
11076
+ *
11077
+ * ```js
11078
+ * I.waitForCookie("token");
11079
+ * ```
11080
+ * @param name - expected cookie name.
11081
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
11082
+ * @returns automatically synchronized promise through #recorder
11083
+ */
11084
+ waitForCookie(name: string, sec?: number): void;
10710
11085
  /**
10711
11086
  * Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
10712
11087
  * Don't confuse popups with modal windows, as created by [various
@@ -11300,10 +11675,122 @@ declare namespace CodeceptJS {
11300
11675
  * Placeholder for ~ locator only test case write once run on both Appium and WebDriver.
11301
11676
  */
11302
11677
  runInWeb(): void;
11678
+ /**
11679
+ * _Note:_ Only works when devtoolsProtocol is enabled.
11680
+ *
11681
+ * Resets all recorded network requests.
11682
+ *
11683
+ * ```js
11684
+ * I.flushNetworkTraffics();
11685
+ * ```
11686
+ */
11687
+ flushNetworkTraffics(): void;
11688
+ /**
11689
+ * _Note:_ Only works when devtoolsProtocol is enabled.
11690
+ *
11691
+ * Stops recording of network traffic. Recorded traffic is not flashed.
11692
+ *
11693
+ * ```js
11694
+ * I.stopRecordingTraffic();
11695
+ * ```
11696
+ */
11697
+ stopRecordingTraffic(): void;
11698
+ /**
11699
+ * _Note:_ Only works when devtoolsProtocol is enabled.
11700
+ *
11701
+ * Starts recording the network traffics.
11702
+ * This also resets recorded network requests.
11703
+ *
11704
+ * ```js
11705
+ * I.startRecordingTraffic();
11706
+ * ```
11707
+ * @returns automatically synchronized promise through #recorder
11708
+ */
11709
+ startRecordingTraffic(): void;
11710
+ /**
11711
+ * _Note:_ Only works when devtoolsProtocol is enabled.
11712
+ *
11713
+ * Grab the recording network traffics
11714
+ *
11715
+ * ```js
11716
+ * const traffics = await I.grabRecordedNetworkTraffics();
11717
+ * expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
11718
+ * expect(traffics[0].response.status).to.equal(200);
11719
+ * expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
11720
+ * ```
11721
+ * @returns recorded network traffics
11722
+ */
11723
+ grabRecordedNetworkTraffics(): any[];
11724
+ /**
11725
+ * _Note:_ Only works when devtoolsProtocol is enabled.
11726
+ *
11727
+ * Verifies that a certain request is part of network traffic.
11728
+ *
11729
+ * ```js
11730
+ * // checking the request url contains certain query strings
11731
+ * I.amOnPage('https://openai.com/blog/chatgpt');
11732
+ * I.startRecordingTraffic();
11733
+ * await I.seeTraffic({
11734
+ * name: 'sentry event',
11735
+ * url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
11736
+ * parameters: {
11737
+ * width: '1919',
11738
+ * height: '1138',
11739
+ * },
11740
+ * });
11741
+ * ```
11742
+ *
11743
+ * ```js
11744
+ * // checking the request url contains certain post data
11745
+ * I.amOnPage('https://openai.com/blog/chatgpt');
11746
+ * I.startRecordingTraffic();
11747
+ * await I.seeTraffic({
11748
+ * name: 'event',
11749
+ * url: 'https://cloudflareinsights.com/cdn-cgi/rum',
11750
+ * requestPostData: {
11751
+ * st: 2,
11752
+ * },
11753
+ * });
11754
+ * ```
11755
+ * @param opts - options when checking the traffic network.
11756
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
11757
+ * @param opts.url - Expected URL of request in network traffic
11758
+ * @param [opts.parameters] - Expected parameters of that request in network traffic
11759
+ * @param [opts.requestPostData] - Expected that request contains post data in network traffic
11760
+ * @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
11761
+ * @returns automatically synchronized promise through #recorder
11762
+ */
11763
+ seeTraffic(opts: {
11764
+ name: string;
11765
+ url: string;
11766
+ parameters?: any;
11767
+ requestPostData?: any;
11768
+ timeout?: number;
11769
+ }): void;
11770
+ /**
11771
+ * _Note:_ Only works when devtoolsProtocol is enabled.
11772
+ *
11773
+ * Verifies that a certain request is not part of network traffic.
11774
+ *
11775
+ * Examples:
11776
+ *
11777
+ * ```js
11778
+ * I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
11779
+ * I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
11780
+ * ```
11781
+ * @param opts - options when checking the traffic network.
11782
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
11783
+ * @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
11784
+ * @returns automatically synchronized promise through #recorder
11785
+ */
11786
+ dontSeeTraffic(opts: {
11787
+ name: string;
11788
+ url: string | RegExp;
11789
+ }): void;
11303
11790
  }
11304
11791
  interface ActorStatic {
11305
11792
  /**
11306
- * add print comment method`
11793
+ * Print the comment on log. Also, adding a step in the `Test.steps` object
11307
11794
  */
11308
11795
  say(msg: string, color?: string): void;
11309
11796
  /**
@@ -11637,6 +12124,7 @@ declare namespace CodeceptJS {
11637
12124
  isShadow(): boolean;
11638
12125
  isFrame(): boolean;
11639
12126
  isCSS(): boolean;
12127
+ isPlaywrightLocator(): boolean;
11640
12128
  isNull(): boolean;
11641
12129
  isXPath(): boolean;
11642
12130
  isCustom(): boolean;
@@ -11889,14 +12377,14 @@ declare namespace CodeceptJS {
11889
12377
  * Detox provides a grey box testing for mobile applications, playing especially good for React Native apps.
11890
12378
  *
11891
12379
  * Detox plays quite differently from Appium. To establish detox testing you need to build a mobile application in a special way to inject Detox code.
11892
- * This why **Detox is grey box testing** solution, so you need an access to application source code, and a way to build and execute it on emulator.
12380
+ * This why **Detox is grey box testing** solution, so you need access to application source code, and a way to build and execute it on emulator.
11893
12381
  *
11894
12382
  * Comparing to Appium, Detox runs faster and more stable but requires an additional setup for build.
11895
12383
  *
11896
12384
  * ### Setup
11897
12385
  *
11898
- * 1. [Install and configure Detox for iOS](https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md) and [Android](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md)
11899
- * 2. [Build an application](https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md#step-4-build-your-app-and-run-detox-tests) using `detox build` command.
12386
+ * 1. [Install and configure Detox](https://wix.github.io/Detox/docs/introduction/project-setup)
12387
+ * 2. [Build an application](https://wix.github.io/Detox/docs/introduction/project-setup#step-5-build-the-app) using `detox build` command.
11900
12388
  * 3. Install [CodeceptJS](https://codecept.io) and detox-helper:
11901
12389
  *
11902
12390
  * ```
@@ -11909,15 +12397,28 @@ declare namespace CodeceptJS {
11909
12397
  *
11910
12398
  * ```js
11911
12399
  * "detox": {
11912
- * "configurations": {
11913
- * "ios.sim.debug": {
11914
- * "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
11915
- * "build": "xcodebuild -project ios/example.xcodeproj -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
11916
- * "type": "ios.simulator",
11917
- * "name": "iPhone 7"
11918
- * }
11919
- * }
11920
- * }
12400
+ * "configurations": {
12401
+ * "ios.sim.debug": {
12402
+ * "device": "simulator",
12403
+ * "app": "ios.debug"
12404
+ * }
12405
+ * },
12406
+ * "apps": {
12407
+ * "ios.debug": {
12408
+ * "type": "ios.app",
12409
+ * "binaryPath": "../test/ios/build/Build/Products/Debug-iphonesimulator/MyTestApp.app",
12410
+ * "build": "xcodebuild -workspace ../test/ios/MyTestApp.xcworkspace -scheme MyTestApp -configuration Debug -sdk iphonesimulator -derivedDataPath ../test/ios/build"
12411
+ * }
12412
+ * },
12413
+ * "devices": {
12414
+ * "simulator": {
12415
+ * "type": "ios.simulator",
12416
+ * "device": {
12417
+ * "type": "iPhone 15"
12418
+ * }
12419
+ * }
12420
+ * }
12421
+ * }
11921
12422
  * ```
11922
12423
  *
11923
12424
  *
@@ -12012,6 +12513,14 @@ declare namespace CodeceptJS {
12012
12513
  * ```
12013
12514
  */
12014
12515
  setPortraitOrientation(): void;
12516
+ /**
12517
+ * Grab the device platform
12518
+ *
12519
+ * ```js
12520
+ * const platform = await I.grabPlatform();
12521
+ * ```
12522
+ */
12523
+ grabPlatform(): void;
12015
12524
  /**
12016
12525
  * Execute code only on iOS
12017
12526
  *
@@ -12101,6 +12610,19 @@ declare namespace CodeceptJS {
12101
12610
  * ```
12102
12611
  */
12103
12612
  click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): void;
12613
+ /**
12614
+ * Clicks on an element.
12615
+ * Element can be located by its label
12616
+ *
12617
+ * The second parameter is a context (id | type | accessibility id) to narrow the search.
12618
+ *
12619
+ *
12620
+ * ```js
12621
+ * I.tapByLabel('Login'); // locate by text
12622
+ * I.tapByLabel('Login', '#nav'); // locate by text inside #nav
12623
+ * ```
12624
+ */
12625
+ tapByLabel(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): void;
12104
12626
  /**
12105
12627
  * Performs click on element with horizontal and vertical offset.
12106
12628
  * An element is located by text, id, accessibility id.
@@ -12151,6 +12673,17 @@ declare namespace CodeceptJS {
12151
12673
  * @param [context = null] - context element
12152
12674
  */
12153
12675
  seeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): void;
12676
+ /**
12677
+ * Checks if an element exists.
12678
+ *
12679
+ * ```js
12680
+ * I.checkIfElementExists('~edit'); // located by accessibility id
12681
+ * I.checkIfElementExists('~edit', '#menu'); // element inside #menu
12682
+ * ```
12683
+ * @param locator - element to locate
12684
+ * @param [context = null] - context element
12685
+ */
12686
+ checkIfElementExists(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): void;
12154
12687
  /**
12155
12688
  * Checks that element is not visible.
12156
12689
  * Use second parameter to narrow down the search.
@@ -12200,6 +12733,18 @@ declare namespace CodeceptJS {
12200
12733
  * @param value - value to fill
12201
12734
  */
12202
12735
  fillField(field: CodeceptJS.LocatorOrString, value: string): void;
12736
+ /**
12737
+ * Taps return key.
12738
+ * A field can be located by text, accessibility id, id.
12739
+ *
12740
+ * ```js
12741
+ * I.tapReturnKey('Username');
12742
+ * I.tapReturnKey('~name');
12743
+ * I.tapReturnKey({ android: 'NAME', ios: 'name' });
12744
+ * ```
12745
+ * @param field - an input element to fill in
12746
+ */
12747
+ tapReturnKey(field: CodeceptJS.LocatorOrString): void;
12203
12748
  /**
12204
12749
  * Clears a text field.
12205
12750
  * A field can be located by text, accessibility id, id.
@@ -12325,7 +12870,7 @@ declare namespace CodeceptJS {
12325
12870
  */
12326
12871
  waitForElementVisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
12327
12872
  /**
12328
- * Waits an elment to become not visible.
12873
+ * Waits an elmenet to become not visible.
12329
12874
  *
12330
12875
  * ```js
12331
12876
  * I.waitToHide('#message', 2); // wait for 2 seconds
@@ -12334,6 +12879,14 @@ declare namespace CodeceptJS {
12334
12879
  * @param [sec = 5] - number of seconds to wait
12335
12880
  */
12336
12881
  waitToHide(locator: CodeceptJS.LocatorOrString, sec?: number): void;
12882
+ /**
12883
+ * Scrolls within a scrollable container to an element.
12884
+ * @param targetLocator - Locator of the element to scroll to
12885
+ * @param containerLocator - Locator of the scrollable container
12886
+ * @param direction - 'up' or 'down'
12887
+ * @param [offset = 100] - Offset for scroll, can be adjusted based on need
12888
+ */
12889
+ scrollToElement(targetLocator: CodeceptJS.LocatorOrString, containerLocator: CodeceptJS.LocatorOrString, direction?: string, offset?: number): void;
12337
12890
  }
12338
12891
  /**
12339
12892
  * Abstract class.