codeceptjs 3.5.12-beta.5 → 3.5.12-beta.7

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 (217) hide show
  1. package/lib/helper/MockServer.js +215 -0
  2. package/lib/helper/Playwright.js +43 -22
  3. package/lib/helper/Puppeteer.js +25 -6
  4. package/lib/helper/WebDriver.js +25 -4
  5. package/lib/helper/errors/ElementAssertion.js +38 -0
  6. package/package.json +6 -5
  7. package/typings/index.d.ts +16 -0
  8. package/typings/promiseBasedTypes.d.ts +182 -0
  9. package/typings/types.d.ts +182 -0
  10. package/docs/advanced.md +0 -351
  11. package/docs/ai.md +0 -248
  12. package/docs/api.md +0 -323
  13. package/docs/basics.md +0 -979
  14. package/docs/bdd.md +0 -539
  15. package/docs/best.md +0 -237
  16. package/docs/books.md +0 -37
  17. package/docs/bootstrap.md +0 -135
  18. package/docs/build/ApiDataFactory.js +0 -410
  19. package/docs/build/Appium.js +0 -2027
  20. package/docs/build/Expect.js +0 -422
  21. package/docs/build/FileSystem.js +0 -228
  22. package/docs/build/GraphQL.js +0 -229
  23. package/docs/build/GraphQLDataFactory.js +0 -309
  24. package/docs/build/JSONResponse.js +0 -338
  25. package/docs/build/Mochawesome.js +0 -71
  26. package/docs/build/Nightmare.js +0 -2152
  27. package/docs/build/OpenAI.js +0 -126
  28. package/docs/build/Playwright.js +0 -5110
  29. package/docs/build/Protractor.js +0 -2706
  30. package/docs/build/Puppeteer.js +0 -3905
  31. package/docs/build/REST.js +0 -344
  32. package/docs/build/TestCafe.js +0 -2125
  33. package/docs/build/WebDriver.js +0 -4240
  34. package/docs/changelog.md +0 -2572
  35. package/docs/commands.md +0 -266
  36. package/docs/community-helpers.md +0 -58
  37. package/docs/configuration.md +0 -157
  38. package/docs/continuous-integration.md +0 -22
  39. package/docs/custom-helpers.md +0 -306
  40. package/docs/data.md +0 -379
  41. package/docs/detox.md +0 -235
  42. package/docs/docker.md +0 -136
  43. package/docs/email.md +0 -183
  44. package/docs/examples.md +0 -149
  45. package/docs/helpers/ApiDataFactory.md +0 -266
  46. package/docs/helpers/Appium.md +0 -1374
  47. package/docs/helpers/Detox.md +0 -586
  48. package/docs/helpers/Expect.md +0 -275
  49. package/docs/helpers/FileSystem.md +0 -152
  50. package/docs/helpers/GraphQL.md +0 -151
  51. package/docs/helpers/GraphQLDataFactory.md +0 -226
  52. package/docs/helpers/JSONResponse.md +0 -254
  53. package/docs/helpers/Mochawesome.md +0 -8
  54. package/docs/helpers/MockRequest.md +0 -377
  55. package/docs/helpers/Nightmare.md +0 -1305
  56. package/docs/helpers/OpenAI.md +0 -70
  57. package/docs/helpers/Playwright.md +0 -2759
  58. package/docs/helpers/Polly.md +0 -44
  59. package/docs/helpers/Protractor.md +0 -1769
  60. package/docs/helpers/Puppeteer-firefox.md +0 -86
  61. package/docs/helpers/Puppeteer.md +0 -2317
  62. package/docs/helpers/REST.md +0 -218
  63. package/docs/helpers/TestCafe.md +0 -1321
  64. package/docs/helpers/WebDriver.md +0 -2547
  65. package/docs/hooks.md +0 -340
  66. package/docs/index.md +0 -111
  67. package/docs/installation.md +0 -75
  68. package/docs/internal-api.md +0 -266
  69. package/docs/locators.md +0 -339
  70. package/docs/mobile-react-native-locators.md +0 -67
  71. package/docs/mobile.md +0 -338
  72. package/docs/pageobjects.md +0 -291
  73. package/docs/parallel.md +0 -400
  74. package/docs/playwright.md +0 -632
  75. package/docs/plugins.md +0 -1259
  76. package/docs/puppeteer.md +0 -316
  77. package/docs/quickstart.md +0 -162
  78. package/docs/react.md +0 -70
  79. package/docs/reports.md +0 -392
  80. package/docs/secrets.md +0 -36
  81. package/docs/shadow.md +0 -68
  82. package/docs/shared/keys.mustache +0 -31
  83. package/docs/shared/react.mustache +0 -1
  84. package/docs/testcafe.md +0 -174
  85. package/docs/translation.md +0 -247
  86. package/docs/tutorial.md +0 -271
  87. package/docs/typescript.md +0 -180
  88. package/docs/ui.md +0 -59
  89. package/docs/videos.md +0 -28
  90. package/docs/visual.md +0 -202
  91. package/docs/vue.md +0 -143
  92. package/docs/webapi/amOnPage.mustache +0 -11
  93. package/docs/webapi/appendField.mustache +0 -11
  94. package/docs/webapi/attachFile.mustache +0 -12
  95. package/docs/webapi/blur.mustache +0 -18
  96. package/docs/webapi/checkOption.mustache +0 -13
  97. package/docs/webapi/clearCookie.mustache +0 -9
  98. package/docs/webapi/clearField.mustache +0 -9
  99. package/docs/webapi/click.mustache +0 -25
  100. package/docs/webapi/clickLink.mustache +0 -8
  101. package/docs/webapi/closeCurrentTab.mustache +0 -7
  102. package/docs/webapi/closeOtherTabs.mustache +0 -8
  103. package/docs/webapi/dontSee.mustache +0 -11
  104. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +0 -10
  105. package/docs/webapi/dontSeeCookie.mustache +0 -8
  106. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +0 -10
  107. package/docs/webapi/dontSeeElement.mustache +0 -8
  108. package/docs/webapi/dontSeeElementInDOM.mustache +0 -8
  109. package/docs/webapi/dontSeeInCurrentUrl.mustache +0 -4
  110. package/docs/webapi/dontSeeInField.mustache +0 -11
  111. package/docs/webapi/dontSeeInSource.mustache +0 -8
  112. package/docs/webapi/dontSeeInTitle.mustache +0 -8
  113. package/docs/webapi/doubleClick.mustache +0 -13
  114. package/docs/webapi/downloadFile.mustache +0 -12
  115. package/docs/webapi/dragAndDrop.mustache +0 -9
  116. package/docs/webapi/dragSlider.mustache +0 -11
  117. package/docs/webapi/executeAsyncScript.mustache +0 -24
  118. package/docs/webapi/executeScript.mustache +0 -26
  119. package/docs/webapi/fillField.mustache +0 -16
  120. package/docs/webapi/focus.mustache +0 -13
  121. package/docs/webapi/forceClick.mustache +0 -28
  122. package/docs/webapi/forceRightClick.mustache +0 -18
  123. package/docs/webapi/grabAllWindowHandles.mustache +0 -7
  124. package/docs/webapi/grabAttributeFrom.mustache +0 -10
  125. package/docs/webapi/grabAttributeFromAll.mustache +0 -9
  126. package/docs/webapi/grabBrowserLogs.mustache +0 -9
  127. package/docs/webapi/grabCookie.mustache +0 -11
  128. package/docs/webapi/grabCssPropertyFrom.mustache +0 -11
  129. package/docs/webapi/grabCssPropertyFromAll.mustache +0 -10
  130. package/docs/webapi/grabCurrentUrl.mustache +0 -9
  131. package/docs/webapi/grabCurrentWindowHandle.mustache +0 -6
  132. package/docs/webapi/grabDataFromPerformanceTiming.mustache +0 -20
  133. package/docs/webapi/grabElementBoundingRect.mustache +0 -20
  134. package/docs/webapi/grabGeoLocation.mustache +0 -8
  135. package/docs/webapi/grabHTMLFrom.mustache +0 -10
  136. package/docs/webapi/grabHTMLFromAll.mustache +0 -9
  137. package/docs/webapi/grabNumberOfOpenTabs.mustache +0 -8
  138. package/docs/webapi/grabNumberOfVisibleElements.mustache +0 -9
  139. package/docs/webapi/grabPageScrollPosition.mustache +0 -8
  140. package/docs/webapi/grabPopupText.mustache +0 -5
  141. package/docs/webapi/grabSource.mustache +0 -8
  142. package/docs/webapi/grabTextFrom.mustache +0 -10
  143. package/docs/webapi/grabTextFromAll.mustache +0 -9
  144. package/docs/webapi/grabTitle.mustache +0 -8
  145. package/docs/webapi/grabValueFrom.mustache +0 -9
  146. package/docs/webapi/grabValueFromAll.mustache +0 -8
  147. package/docs/webapi/grabWebElement.mustache +0 -9
  148. package/docs/webapi/grabWebElements.mustache +0 -9
  149. package/docs/webapi/moveCursorTo.mustache +0 -12
  150. package/docs/webapi/openNewTab.mustache +0 -7
  151. package/docs/webapi/pressKey.mustache +0 -12
  152. package/docs/webapi/pressKeyDown.mustache +0 -12
  153. package/docs/webapi/pressKeyUp.mustache +0 -12
  154. package/docs/webapi/pressKeyWithKeyNormalization.mustache +0 -60
  155. package/docs/webapi/refreshPage.mustache +0 -6
  156. package/docs/webapi/resizeWindow.mustache +0 -6
  157. package/docs/webapi/rightClick.mustache +0 -14
  158. package/docs/webapi/saveElementScreenshot.mustache +0 -10
  159. package/docs/webapi/saveScreenshot.mustache +0 -12
  160. package/docs/webapi/say.mustache +0 -10
  161. package/docs/webapi/scrollIntoView.mustache +0 -11
  162. package/docs/webapi/scrollPageToBottom.mustache +0 -6
  163. package/docs/webapi/scrollPageToTop.mustache +0 -6
  164. package/docs/webapi/scrollTo.mustache +0 -12
  165. package/docs/webapi/see.mustache +0 -11
  166. package/docs/webapi/seeAttributesOnElements.mustache +0 -9
  167. package/docs/webapi/seeCheckboxIsChecked.mustache +0 -10
  168. package/docs/webapi/seeCookie.mustache +0 -8
  169. package/docs/webapi/seeCssPropertiesOnElements.mustache +0 -9
  170. package/docs/webapi/seeCurrentUrlEquals.mustache +0 -11
  171. package/docs/webapi/seeElement.mustache +0 -8
  172. package/docs/webapi/seeElementInDOM.mustache +0 -8
  173. package/docs/webapi/seeInCurrentUrl.mustache +0 -8
  174. package/docs/webapi/seeInField.mustache +0 -12
  175. package/docs/webapi/seeInPopup.mustache +0 -8
  176. package/docs/webapi/seeInSource.mustache +0 -7
  177. package/docs/webapi/seeInTitle.mustache +0 -8
  178. package/docs/webapi/seeNumberOfElements.mustache +0 -11
  179. package/docs/webapi/seeNumberOfVisibleElements.mustache +0 -10
  180. package/docs/webapi/seeTextEquals.mustache +0 -9
  181. package/docs/webapi/seeTitleEquals.mustache +0 -8
  182. package/docs/webapi/selectOption.mustache +0 -21
  183. package/docs/webapi/setCookie.mustache +0 -16
  184. package/docs/webapi/setGeoLocation.mustache +0 -12
  185. package/docs/webapi/switchTo.mustache +0 -9
  186. package/docs/webapi/switchToNextTab.mustache +0 -10
  187. package/docs/webapi/switchToPreviousTab.mustache +0 -10
  188. package/docs/webapi/type.mustache +0 -21
  189. package/docs/webapi/uncheckOption.mustache +0 -13
  190. package/docs/webapi/wait.mustache +0 -8
  191. package/docs/webapi/waitForClickable.mustache +0 -11
  192. package/docs/webapi/waitForDetached.mustache +0 -10
  193. package/docs/webapi/waitForElement.mustache +0 -11
  194. package/docs/webapi/waitForEnabled.mustache +0 -6
  195. package/docs/webapi/waitForFunction.mustache +0 -17
  196. package/docs/webapi/waitForInvisible.mustache +0 -10
  197. package/docs/webapi/waitForNumberOfTabs.mustache +0 -9
  198. package/docs/webapi/waitForText.mustache +0 -13
  199. package/docs/webapi/waitForValue.mustache +0 -10
  200. package/docs/webapi/waitForVisible.mustache +0 -10
  201. package/docs/webapi/waitInUrl.mustache +0 -9
  202. package/docs/webapi/waitNumberOfVisibleElements.mustache +0 -10
  203. package/docs/webapi/waitToHide.mustache +0 -10
  204. package/docs/webapi/waitUrlEquals.mustache +0 -10
  205. package/docs/webdriver.md +0 -701
  206. package/docs/wiki/Books-&-Posts.md +0 -27
  207. package/docs/wiki/Community-Helpers-&-Plugins.md +0 -53
  208. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -61
  209. package/docs/wiki/Examples.md +0 -145
  210. package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
  211. package/docs/wiki/Home.md +0 -16
  212. package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +0 -83
  213. package/docs/wiki/Release-Process.md +0 -24
  214. package/docs/wiki/Roadmap.md +0 -23
  215. package/docs/wiki/Tests.md +0 -1393
  216. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -153
  217. package/docs/wiki/Videos.md +0 -19
@@ -1732,6 +1732,188 @@ declare namespace CodeceptJS {
1732
1732
  */
1733
1733
  seeResponseMatchesJsonSchema(fnOrSchema: any): Promise<any>;
1734
1734
  }
1735
+ /**
1736
+ * ## Configuration
1737
+ *
1738
+ * This helper should be configured in codecept.conf.(js|ts)
1739
+ * @property [port = 9393] - Mock server port
1740
+ * @property [host = "0.0.0.0"] - Mock server host
1741
+ * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
1742
+ */
1743
+ type MockServerConfig = {
1744
+ port?: number;
1745
+ host?: string;
1746
+ httpsOpts?: any;
1747
+ };
1748
+ /**
1749
+ * MockServer
1750
+ *
1751
+ * 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.
1752
+ *
1753
+ * <!-- configuration -->
1754
+ *
1755
+ * #### Examples
1756
+ *
1757
+ * You can seamlessly integrate MockServer with other helpers like REST or Playwright. Here's a configuration example inside the `codecept.conf.js` file:
1758
+ *
1759
+ * ```javascript
1760
+ * {
1761
+ * helpers: {
1762
+ * REST: {...},
1763
+ * MockServer: {
1764
+ * // default mock server config
1765
+ * port: 9393,
1766
+ * host: '0.0.0.0',
1767
+ * httpsOpts: {
1768
+ * key: '',
1769
+ * cert: '',
1770
+ * },
1771
+ * },
1772
+ * }
1773
+ * }
1774
+ * ```
1775
+ *
1776
+ * #### Adding Interactions
1777
+ *
1778
+ * 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.
1779
+ *
1780
+ * ```javascript
1781
+ * I.addInteractionToMockServer({
1782
+ * request: {
1783
+ * method: 'GET',
1784
+ * path: '/api/hello'
1785
+ * },
1786
+ * response: {
1787
+ * status: 200,
1788
+ * body: {
1789
+ * 'say': 'hello to mock server'
1790
+ * }
1791
+ * }
1792
+ * });
1793
+ * ```
1794
+ *
1795
+ * #### Request Matching
1796
+ *
1797
+ * 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.
1798
+ *
1799
+ * - Strong match on HTTP Method, Path, Query Params & JSON body.
1800
+ * - Loose match on Headers.
1801
+ *
1802
+ * ##### Strong Match on Query Params
1803
+ *
1804
+ * You can send different responses based on query parameters:
1805
+ *
1806
+ * ```javascript
1807
+ * I.addInteractionToMockServer({
1808
+ * request: {
1809
+ * method: 'GET',
1810
+ * path: '/api/users',
1811
+ * queryParams: {
1812
+ * id: 1
1813
+ * }
1814
+ * },
1815
+ * response: {
1816
+ * status: 200,
1817
+ * body: 'user 1'
1818
+ * }
1819
+ * });
1820
+ *
1821
+ * I.addInteractionToMockServer({
1822
+ * request: {
1823
+ * method: 'GET',
1824
+ * path: '/api/users',
1825
+ * queryParams: {
1826
+ * id: 2
1827
+ * }
1828
+ * },
1829
+ * response: {
1830
+ * status: 200,
1831
+ * body: 'user 2'
1832
+ * }
1833
+ * });
1834
+ * ```
1835
+ *
1836
+ * - GET to `/api/users?id=1` will return 'user 1'.
1837
+ * - GET to `/api/users?id=2` will return 'user 2'.
1838
+ * - For all other requests, it returns a 404 status code.
1839
+ *
1840
+ * ##### Loose Match on Body
1841
+ *
1842
+ * When `strict` is set to false, it performs a loose match on query params and response body:
1843
+ *
1844
+ * ```javascript
1845
+ * I.addInteractionToMockServer({
1846
+ * strict: false,
1847
+ * request: {
1848
+ * method: 'POST',
1849
+ * path: '/api/users',
1850
+ * body: {
1851
+ * name: 'john'
1852
+ * }
1853
+ * },
1854
+ * response: {
1855
+ * status: 200
1856
+ * }
1857
+ * });
1858
+ * ```
1859
+ *
1860
+ * - POST to `/api/users` with the body containing `name` as 'john' will return a 200 status code.
1861
+ * - POST to `/api/users` without the `name` property in the body will return a 404 status code.
1862
+ *
1863
+ * Happy testing with MockServer in CodeceptJS! 🚀
1864
+ *
1865
+ * ## Methods
1866
+ */
1867
+ class MockServer {
1868
+ /**
1869
+ * Start the mock server
1870
+ * @param [port] - start the mock server with given port
1871
+ */
1872
+ startMockServer(port?: number): Promise<any>;
1873
+ /**
1874
+ * Stop the mock server
1875
+ */
1876
+ stopMockServer(): Promise<any>;
1877
+ /**
1878
+ * An interaction adds behavior to the mock server
1879
+ *
1880
+ *
1881
+ * ```js
1882
+ * I.addInteractionToMockServer({
1883
+ * request: {
1884
+ * method: 'GET',
1885
+ * path: '/api/hello'
1886
+ * },
1887
+ * response: {
1888
+ * status: 200,
1889
+ * body: {
1890
+ * 'say': 'hello to mock server'
1891
+ * }
1892
+ * }
1893
+ * });
1894
+ * ```
1895
+ * ```js
1896
+ * // with query params
1897
+ * I.addInteractionToMockServer({
1898
+ * request: {
1899
+ * method: 'GET',
1900
+ * path: '/api/hello',
1901
+ * queryParams: {
1902
+ * id: 2
1903
+ * }
1904
+ * },
1905
+ * response: {
1906
+ * status: 200,
1907
+ * body: {
1908
+ * 'say': 'hello to mock server'
1909
+ * }
1910
+ * }
1911
+ * });
1912
+ * ```
1913
+ * @param interaction - add behavior to the mock server
1914
+ */
1915
+ addInteractionToMockServer(interaction: CodeceptJS.MockInteraction | any): Promise<any>;
1916
+ }
1735
1917
  /**
1736
1918
  * Nightmare helper wraps [Nightmare](https://github.com/segmentio/nightmare) library to provide
1737
1919
  * fastest headless testing using Electron engine. Unlike Selenium-based drivers this uses
@@ -1759,6 +1759,188 @@ declare namespace CodeceptJS {
1759
1759
  */
1760
1760
  seeResponseMatchesJsonSchema(fnOrSchema: any): void;
1761
1761
  }
1762
+ /**
1763
+ * ## Configuration
1764
+ *
1765
+ * This helper should be configured in codecept.conf.(js|ts)
1766
+ * @property [port = 9393] - Mock server port
1767
+ * @property [host = "0.0.0.0"] - Mock server host
1768
+ * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
1769
+ */
1770
+ type MockServerConfig = {
1771
+ port?: number;
1772
+ host?: string;
1773
+ httpsOpts?: any;
1774
+ };
1775
+ /**
1776
+ * MockServer
1777
+ *
1778
+ * 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.
1779
+ *
1780
+ * <!-- configuration -->
1781
+ *
1782
+ * #### Examples
1783
+ *
1784
+ * You can seamlessly integrate MockServer with other helpers like REST or Playwright. Here's a configuration example inside the `codecept.conf.js` file:
1785
+ *
1786
+ * ```javascript
1787
+ * {
1788
+ * helpers: {
1789
+ * REST: {...},
1790
+ * MockServer: {
1791
+ * // default mock server config
1792
+ * port: 9393,
1793
+ * host: '0.0.0.0',
1794
+ * httpsOpts: {
1795
+ * key: '',
1796
+ * cert: '',
1797
+ * },
1798
+ * },
1799
+ * }
1800
+ * }
1801
+ * ```
1802
+ *
1803
+ * #### Adding Interactions
1804
+ *
1805
+ * 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.
1806
+ *
1807
+ * ```javascript
1808
+ * I.addInteractionToMockServer({
1809
+ * request: {
1810
+ * method: 'GET',
1811
+ * path: '/api/hello'
1812
+ * },
1813
+ * response: {
1814
+ * status: 200,
1815
+ * body: {
1816
+ * 'say': 'hello to mock server'
1817
+ * }
1818
+ * }
1819
+ * });
1820
+ * ```
1821
+ *
1822
+ * #### Request Matching
1823
+ *
1824
+ * 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.
1825
+ *
1826
+ * - Strong match on HTTP Method, Path, Query Params & JSON body.
1827
+ * - Loose match on Headers.
1828
+ *
1829
+ * ##### Strong Match on Query Params
1830
+ *
1831
+ * You can send different responses based on query parameters:
1832
+ *
1833
+ * ```javascript
1834
+ * I.addInteractionToMockServer({
1835
+ * request: {
1836
+ * method: 'GET',
1837
+ * path: '/api/users',
1838
+ * queryParams: {
1839
+ * id: 1
1840
+ * }
1841
+ * },
1842
+ * response: {
1843
+ * status: 200,
1844
+ * body: 'user 1'
1845
+ * }
1846
+ * });
1847
+ *
1848
+ * I.addInteractionToMockServer({
1849
+ * request: {
1850
+ * method: 'GET',
1851
+ * path: '/api/users',
1852
+ * queryParams: {
1853
+ * id: 2
1854
+ * }
1855
+ * },
1856
+ * response: {
1857
+ * status: 200,
1858
+ * body: 'user 2'
1859
+ * }
1860
+ * });
1861
+ * ```
1862
+ *
1863
+ * - GET to `/api/users?id=1` will return 'user 1'.
1864
+ * - GET to `/api/users?id=2` will return 'user 2'.
1865
+ * - For all other requests, it returns a 404 status code.
1866
+ *
1867
+ * ##### Loose Match on Body
1868
+ *
1869
+ * When `strict` is set to false, it performs a loose match on query params and response body:
1870
+ *
1871
+ * ```javascript
1872
+ * I.addInteractionToMockServer({
1873
+ * strict: false,
1874
+ * request: {
1875
+ * method: 'POST',
1876
+ * path: '/api/users',
1877
+ * body: {
1878
+ * name: 'john'
1879
+ * }
1880
+ * },
1881
+ * response: {
1882
+ * status: 200
1883
+ * }
1884
+ * });
1885
+ * ```
1886
+ *
1887
+ * - POST to `/api/users` with the body containing `name` as 'john' will return a 200 status code.
1888
+ * - POST to `/api/users` without the `name` property in the body will return a 404 status code.
1889
+ *
1890
+ * Happy testing with MockServer in CodeceptJS! 🚀
1891
+ *
1892
+ * ## Methods
1893
+ */
1894
+ class MockServer {
1895
+ /**
1896
+ * Start the mock server
1897
+ * @param [port] - start the mock server with given port
1898
+ */
1899
+ startMockServer(port?: number): void;
1900
+ /**
1901
+ * Stop the mock server
1902
+ */
1903
+ stopMockServer(): void;
1904
+ /**
1905
+ * An interaction adds behavior to the mock server
1906
+ *
1907
+ *
1908
+ * ```js
1909
+ * I.addInteractionToMockServer({
1910
+ * request: {
1911
+ * method: 'GET',
1912
+ * path: '/api/hello'
1913
+ * },
1914
+ * response: {
1915
+ * status: 200,
1916
+ * body: {
1917
+ * 'say': 'hello to mock server'
1918
+ * }
1919
+ * }
1920
+ * });
1921
+ * ```
1922
+ * ```js
1923
+ * // with query params
1924
+ * I.addInteractionToMockServer({
1925
+ * request: {
1926
+ * method: 'GET',
1927
+ * path: '/api/hello',
1928
+ * queryParams: {
1929
+ * id: 2
1930
+ * }
1931
+ * },
1932
+ * response: {
1933
+ * status: 200,
1934
+ * body: {
1935
+ * 'say': 'hello to mock server'
1936
+ * }
1937
+ * }
1938
+ * });
1939
+ * ```
1940
+ * @param interaction - add behavior to the mock server
1941
+ */
1942
+ addInteractionToMockServer(interaction: CodeceptJS.MockInteraction | any): void;
1943
+ }
1762
1944
  /**
1763
1945
  * Nightmare helper wraps [Nightmare](https://github.com/segmentio/nightmare) library to provide
1764
1946
  * fastest headless testing using Electron engine. Unlike Selenium-based drivers this uses