codeceptjs 2.3.4 → 2.4.1

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 (269) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +28 -6
  3. package/bin/codecept.js +42 -0
  4. package/docs/advanced.md +45 -1
  5. package/docs/angular.md +3 -3
  6. package/docs/basics.md +162 -118
  7. package/docs/bdd.md +30 -5
  8. package/docs/best.md +8 -6
  9. package/docs/books.md +6 -1
  10. package/docs/build/Appium.js +95 -85
  11. package/docs/build/FileSystem.js +48 -3
  12. package/docs/build/GraphQL.js +3 -2
  13. package/docs/build/GraphQLDataFactory.js +1 -0
  14. package/docs/build/Mochawesome.js +3 -2
  15. package/docs/build/MockRequest.js +23 -5
  16. package/docs/build/Nightmare.js +87 -128
  17. package/docs/build/Protractor.js +107 -155
  18. package/docs/build/Puppeteer.js +190 -174
  19. package/docs/build/REST.js +13 -9
  20. package/docs/build/SeleniumWebdriver.js +0 -17
  21. package/docs/build/TestCafe.js +164 -158
  22. package/docs/build/WebDriver.js +236 -211
  23. package/docs/build/WebDriverIO.js +218 -187
  24. package/docs/changelog.md +57 -1
  25. package/docs/commands.md +41 -2
  26. package/docs/community-helpers.md +12 -1
  27. package/docs/configuration.md +5 -2
  28. package/docs/continuous-integration.md +22 -0
  29. package/docs/{helpers.md → custom-helpers.md} +16 -10
  30. package/docs/data.md +7 -6
  31. package/docs/detox.md +6 -6
  32. package/docs/email.md +4 -2
  33. package/docs/examples.md +22 -3
  34. package/docs/helpers/ApiDataFactory.md +15 -13
  35. package/docs/helpers/Appium.md +1011 -468
  36. package/docs/helpers/Detox.md +33 -26
  37. package/docs/helpers/FileSystem.md +43 -13
  38. package/docs/helpers/GraphQL.md +17 -15
  39. package/docs/helpers/GraphQLDataFactory.md +15 -13
  40. package/docs/helpers/Mochawesome.md +3 -1
  41. package/docs/helpers/MockRequest.md +37 -19
  42. package/docs/helpers/Nightmare.md +129 -240
  43. package/docs/helpers/Polly.md +1 -1
  44. package/docs/helpers/Protractor.md +157 -298
  45. package/docs/helpers/Puppeteer.md +216 -335
  46. package/docs/helpers/REST.md +29 -24
  47. package/docs/helpers/TestCafe.md +137 -235
  48. package/docs/helpers/WebDriver.md +250 -347
  49. package/docs/hooks.md +14 -10
  50. package/docs/index.md +112 -0
  51. package/docs/installation.md +3 -1
  52. package/docs/locators.md +19 -8
  53. package/docs/mobile-react-native-locators.md +2 -2
  54. package/docs/mobile.md +5 -3
  55. package/docs/nightmare.md +2 -1
  56. package/docs/pageobjects.md +4 -2
  57. package/docs/parallel.md +4 -2
  58. package/docs/plugins.md +41 -15
  59. package/docs/puppeteer.md +8 -6
  60. package/docs/quickstart.md +130 -0
  61. package/docs/react.md +4 -2
  62. package/docs/reports.md +6 -4
  63. package/docs/testcafe.md +10 -8
  64. package/docs/translation.md +4 -2
  65. package/docs/ui.md +56 -0
  66. package/docs/videos.md +11 -2
  67. package/docs/visual.md +7 -5
  68. package/docs/vue.md +121 -0
  69. package/docs/webapi/appendField.mustache +1 -1
  70. package/docs/webapi/attachFile.mustache +1 -1
  71. package/docs/webapi/checkOption.mustache +2 -2
  72. package/docs/webapi/clearCookie.mustache +1 -1
  73. package/docs/webapi/click.mustache +2 -2
  74. package/docs/webapi/clickLink.mustache +2 -2
  75. package/docs/webapi/dontSee.mustache +1 -2
  76. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -1
  77. package/docs/webapi/dontSeeElement.mustache +1 -1
  78. package/docs/webapi/dontSeeElementInDOM.mustache +1 -1
  79. package/docs/webapi/dontSeeInField.mustache +1 -1
  80. package/docs/webapi/doubleClick.mustache +2 -2
  81. package/docs/webapi/downloadFile.mustache +1 -1
  82. package/docs/webapi/dragSlider.mustache +1 -1
  83. package/docs/webapi/executeAsyncScript.mustache +2 -1
  84. package/docs/webapi/executeScript.mustache +2 -1
  85. package/docs/webapi/fillField.mustache +1 -1
  86. package/docs/webapi/grabAttributeFrom.mustache +1 -1
  87. package/docs/webapi/grabBrowserLogs.mustache +1 -1
  88. package/docs/webapi/grabCookie.mustache +2 -2
  89. package/docs/webapi/grabCssPropertyFrom.mustache +1 -1
  90. package/docs/webapi/grabHTMLFrom.mustache +1 -1
  91. package/docs/webapi/grabNumberOfVisibleElements.mustache +1 -1
  92. package/docs/webapi/grabPageScrollPosition.mustache +1 -1
  93. package/docs/webapi/grabTextFrom.mustache +2 -2
  94. package/docs/webapi/grabValueFrom.mustache +1 -1
  95. package/docs/webapi/moveCursorTo.mustache +3 -3
  96. package/docs/webapi/pressKey.mustache +1 -1
  97. package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -1
  98. package/docs/webapi/rightClick.mustache +2 -2
  99. package/docs/webapi/saveScreenshot.mustache +1 -1
  100. package/docs/webapi/scrollIntoView.mustache +10 -0
  101. package/docs/webapi/scrollTo.mustache +3 -3
  102. package/docs/webapi/see.mustache +1 -1
  103. package/docs/webapi/seeAttributesOnElements.mustache +1 -1
  104. package/docs/webapi/seeCheckboxIsChecked.mustache +1 -1
  105. package/docs/webapi/seeCssPropertiesOnElements.mustache +1 -1
  106. package/docs/webapi/seeElement.mustache +1 -1
  107. package/docs/webapi/seeElementInDOM.mustache +1 -1
  108. package/docs/webapi/seeInField.mustache +1 -1
  109. package/docs/webapi/seeNumberOfElements.mustache +1 -1
  110. package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -1
  111. package/docs/webapi/seeTextEquals.mustache +8 -0
  112. package/docs/webapi/selectOption.mustache +2 -2
  113. package/docs/webapi/switchTo.mustache +1 -1
  114. package/docs/webapi/uncheckOption.mustache +2 -2
  115. package/docs/webapi/waitForClickable.mustache +10 -0
  116. package/docs/webapi/waitForDetached.mustache +2 -2
  117. package/docs/webapi/waitForElement.mustache +2 -2
  118. package/docs/webapi/waitForEnabled.mustache +2 -2
  119. package/docs/webapi/waitForFunction.mustache +2 -2
  120. package/docs/webapi/waitForInvisible.mustache +2 -2
  121. package/docs/webapi/waitForText.mustache +2 -2
  122. package/docs/webapi/waitForValue.mustache +1 -1
  123. package/docs/webapi/waitForVisible.mustache +2 -2
  124. package/docs/webapi/waitInUrl.mustache +1 -1
  125. package/docs/webapi/waitNumberOfVisibleElements.mustache +2 -2
  126. package/docs/webapi/waitToHide.mustache +2 -2
  127. package/docs/webapi/waitUntil.mustache +3 -2
  128. package/docs/webapi/waitUrlEquals.mustache +1 -1
  129. package/docs/webdriver.md +20 -18
  130. package/docs/wiki/.git/FETCH_HEAD +1 -0
  131. package/docs/wiki/.git/HEAD +1 -0
  132. package/docs/wiki/.git/ORIG_HEAD +1 -0
  133. package/docs/wiki/.git/config +11 -0
  134. package/docs/wiki/.git/description +1 -0
  135. package/docs/wiki/.git/hooks/applypatch-msg.sample +15 -0
  136. package/docs/wiki/.git/hooks/commit-msg.sample +24 -0
  137. package/docs/wiki/.git/hooks/fsmonitor-watchman.sample +114 -0
  138. package/docs/wiki/.git/hooks/post-update.sample +8 -0
  139. package/docs/wiki/.git/hooks/pre-applypatch.sample +14 -0
  140. package/docs/wiki/.git/hooks/pre-commit.sample +49 -0
  141. package/docs/wiki/.git/hooks/pre-push.sample +53 -0
  142. package/docs/wiki/.git/hooks/pre-rebase.sample +169 -0
  143. package/docs/wiki/.git/hooks/pre-receive.sample +24 -0
  144. package/docs/wiki/.git/hooks/prepare-commit-msg.sample +42 -0
  145. package/docs/wiki/.git/hooks/update.sample +128 -0
  146. package/docs/wiki/.git/index +0 -0
  147. package/docs/wiki/.git/info/exclude +6 -0
  148. package/docs/wiki/.git/logs/HEAD +4 -0
  149. package/docs/wiki/.git/logs/refs/heads/master +4 -0
  150. package/docs/wiki/.git/logs/refs/remotes/origin/HEAD +1 -0
  151. package/docs/wiki/.git/logs/refs/remotes/origin/master +3 -0
  152. package/docs/wiki/.git/objects/00/d216b0774d15db2d0a2a0d4ce249b5251acc55 +3 -0
  153. package/docs/wiki/.git/objects/09/01d87c5241905fdfe3493cfe8f04df4a2685ea +0 -0
  154. package/docs/wiki/.git/objects/0d/bdd0c20c4deb6a8cc81dbbf32ecf8c09238983 +2 -0
  155. package/docs/wiki/.git/objects/1a/c29e4fa82422c52392f22f0f2b8d1a759535bf +0 -0
  156. package/docs/wiki/.git/objects/27/12f92898d3e8f68e229b6cda76570d6c66d781 +0 -0
  157. package/docs/wiki/.git/objects/2d/dbe22c257166b648928eeb9460ecfb71ba702d +0 -0
  158. package/docs/wiki/.git/objects/2f/c942ec3773efd2678d9ff98035c61fcded81a1 +0 -0
  159. package/docs/wiki/.git/objects/40/a2856342c67796b48911a256b764fb06888b94 +5 -0
  160. package/docs/wiki/.git/objects/47/53181844fc4dc563cf3aa5e80462243cb58d38 +0 -0
  161. package/docs/wiki/.git/objects/4e/24a95fb2e4f8ffef51f19b694451a205c06f10 +3 -0
  162. package/docs/wiki/.git/objects/73/31ebd96f3c7e08a9f63f05a25f939afa0d4de1 +0 -0
  163. package/docs/wiki/.git/objects/86/19cbb2289caa502e33fccf0ed14eecf6ba2ba0 +0 -0
  164. package/docs/wiki/.git/objects/a4/72f797d9d74b87c9f71a2b1539d75bb07d1e35 +0 -0
  165. package/docs/wiki/.git/objects/c9/9f3e4bd227d6b050b2e416f9876df49583dbf6 +0 -0
  166. package/docs/wiki/.git/objects/ca/e609b4ef3e0ef85fcbe0d68d1a58246584b915 +0 -0
  167. package/docs/wiki/.git/objects/d5/8386ca72f6d550548f3d71d74e3ac73d5ad488 +0 -0
  168. package/docs/wiki/.git/objects/d9/c6874a6de524bdafeb563a20d847f4fdd59a86 +0 -0
  169. package/docs/wiki/.git/objects/f1/c944675bb38b40ae553b0be36c14674c79af54 +0 -0
  170. package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.idx +0 -0
  171. package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.pack +0 -0
  172. package/docs/wiki/.git/packed-refs +2 -0
  173. package/docs/wiki/.git/refs/heads/master +1 -0
  174. package/docs/wiki/.git/refs/remotes/origin/HEAD +1 -0
  175. package/docs/wiki/.git/refs/remotes/origin/master +1 -0
  176. package/docs/wiki/Books-&-Posts.md +27 -0
  177. package/docs/wiki/Community-Helpers.md +41 -0
  178. package/docs/wiki/Examples.md +138 -0
  179. package/docs/wiki/Home.md +11 -0
  180. package/docs/wiki/Release-process.md +25 -0
  181. package/docs/wiki/Roadmap.md +23 -0
  182. package/docs/wiki/Videos.md +19 -0
  183. package/lib/actor.js +18 -1
  184. package/lib/assert/error.js +3 -3
  185. package/lib/codecept.js +9 -6
  186. package/lib/command/configMigrate.js +7 -6
  187. package/lib/command/definitions.js +98 -350
  188. package/lib/command/generate.js +22 -17
  189. package/lib/command/gherkin/init.js +2 -1
  190. package/lib/command/gherkin/snippets.js +6 -6
  191. package/lib/command/gherkin/steps.js +0 -1
  192. package/lib/command/info.js +40 -0
  193. package/lib/command/init.js +54 -41
  194. package/lib/command/run-multiple.js +5 -4
  195. package/lib/command/run-rerun.js +39 -0
  196. package/lib/command/run-workers.js +4 -6
  197. package/lib/command/run.js +8 -18
  198. package/lib/command/utils.js +23 -2
  199. package/lib/command/workers/runTests.js +1 -2
  200. package/lib/config.js +10 -4
  201. package/lib/container.js +31 -6
  202. package/lib/data/dataTableArgument.js +31 -0
  203. package/lib/data/table.js +4 -0
  204. package/lib/event.js +65 -1
  205. package/lib/helper/Appium.js +52 -38
  206. package/lib/helper/FileSystem.js +48 -3
  207. package/lib/helper/GraphQL.js +3 -2
  208. package/lib/helper/GraphQLDataFactory.js +1 -0
  209. package/lib/helper/Mochawesome.js +3 -2
  210. package/lib/helper/MockRequest.js +23 -5
  211. package/lib/helper/Nightmare.js +5 -6
  212. package/lib/helper/Protractor.js +7 -8
  213. package/lib/helper/Puppeteer.js +76 -20
  214. package/lib/helper/REST.js +13 -9
  215. package/lib/helper/SeleniumWebdriver.js +0 -17
  216. package/lib/helper/TestCafe.js +84 -36
  217. package/lib/helper/WebDriver.js +113 -59
  218. package/lib/helper/WebDriverIO.js +43 -59
  219. package/lib/helper/clientscripts/nightmare.js +66 -4
  220. package/lib/helper/scripts/isElementClickable.js +24 -0
  221. package/lib/helper.js +34 -10
  222. package/lib/history.js +1 -1
  223. package/lib/hooks.js +2 -1
  224. package/lib/index.js +19 -0
  225. package/lib/interfaces/bdd.js +4 -0
  226. package/lib/interfaces/featureConfig.js +10 -3
  227. package/lib/interfaces/gherkin.js +6 -2
  228. package/lib/interfaces/scenarioConfig.js +17 -6
  229. package/lib/listener/config.js +1 -1
  230. package/lib/listener/exit.js +6 -0
  231. package/lib/listener/steps.js +0 -1
  232. package/lib/listener/trace.js +0 -1
  233. package/lib/locator.js +67 -2
  234. package/lib/output.js +53 -0
  235. package/lib/parser.js +2 -71
  236. package/lib/pause.js +3 -2
  237. package/lib/plugin/allure.js +41 -22
  238. package/lib/plugin/autoLogin.js +4 -1
  239. package/lib/plugin/pauseOnFail.js +38 -0
  240. package/lib/plugin/puppeteerCoverage.js +8 -7
  241. package/lib/plugin/screenshotOnFail.js +13 -8
  242. package/lib/plugin/stepByStepReport.js +7 -6
  243. package/lib/plugin/wdio.js +2 -1
  244. package/lib/recorder.js +85 -7
  245. package/lib/rerun.js +81 -0
  246. package/lib/secret.js +6 -0
  247. package/lib/session.js +9 -2
  248. package/lib/step.js +37 -2
  249. package/lib/store.js +5 -1
  250. package/lib/ui.js +34 -8
  251. package/lib/utils.js +6 -13
  252. package/lib/within.js +5 -0
  253. package/package.json +49 -29
  254. package/typings/Mocha.d.ts +21 -0
  255. package/typings/Protractor.d.ts +16 -0
  256. package/typings/index.d.ts +169 -0
  257. package/typings/jsdoc.conf.js +34 -0
  258. package/typings/jsdoc.namespace.js +29 -0
  259. package/typings/types.d.ts +9827 -0
  260. package/typings/utils.d.ts +7 -0
  261. package/docs/acceptance.md +0 -409
  262. package/docs/api/codecept.md +0 -75
  263. package/docs/api/config.md +0 -49
  264. package/docs/api/container.md +0 -66
  265. package/docs/api/helper.md +0 -116
  266. package/docs/api/output.md +0 -67
  267. package/docs/api/recorder.md +0 -63
  268. package/docs/helpers/SeleniumWebdriver.md +0 -92
  269. package/docs/helpers/WebDriverIO.md +0 -1671
@@ -1,10 +1,22 @@
1
1
  if (!window.codeceptjs) {
2
+ /**
3
+ * @alias CodeceptJS.browserCodecept
4
+ * @namespace
5
+ */
2
6
  const codeceptjs = {};
3
7
 
4
- // all found elements are stored here for reuse
8
+ /**
9
+ * all found elements are stored here for reuse
10
+ * @inner
11
+ * @type {Node[]}
12
+ */
5
13
  codeceptjs.elements = [];
6
14
 
7
- // global context changer
15
+ /**
16
+ * global context changer
17
+ * @inner
18
+ * @type {?Node}
19
+ */
8
20
  codeceptjs.within = null;
9
21
 
10
22
  // save
@@ -17,24 +29,50 @@ if (!window.codeceptjs) {
17
29
  return els.map(el => storeElement(el));
18
30
  };
19
31
 
20
- // finders
32
+ /**
33
+ * finders
34
+ * @param {number} id
35
+ * @return {Node}
36
+ */
21
37
  codeceptjs.fetchElement = function (id) {
22
38
  if (!this.elements[id]) throw new Error(`Element (${id}) is not accessible`);
23
39
  return this.elements[id];
24
40
  };
25
41
 
42
+ /**
43
+ * @param {string} by
44
+ * @param {CodeceptJS.ILocator} locator
45
+ * @param {*} [contextEl]
46
+ * @return {number[]}
47
+ */
26
48
  codeceptjs.findAndStoreElements = function (by, locator, contextEl) {
27
49
  return storeElements(this.findElements(by, locator, contextEl));
28
50
  };
29
51
 
52
+ /**
53
+ * @param {string} by
54
+ * @param {CodeceptJS.ILocator} locator
55
+ * @param {*} [contextEl]
56
+ * @return {number | undefined}
57
+ */
30
58
  codeceptjs.findAndStoreElement = function (by, locator, contextEl) {
31
59
  return storeElement(this.findElement(by, locator, contextEl));
32
60
  };
33
61
 
62
+ /**
63
+ * @param {string} by
64
+ * @param {CodeceptJS.ILocator} locator
65
+ */
34
66
  codeceptjs.setWithin = function (by, locator) {
35
67
  this.within = this.findElement(by, locator);
36
68
  };
37
69
 
70
+ /**
71
+ * @param {string} by
72
+ * @param {CodeceptJS.ILocator} locator
73
+ * @param {*} [contextEl]
74
+ * @return {Node[]}
75
+ */
38
76
  codeceptjs.findElements = function (by, locator, contextEl) {
39
77
  let context;
40
78
  if (typeof contextEl !== 'number') {
@@ -78,11 +116,21 @@ if (!window.codeceptjs) {
78
116
  return [];
79
117
  };
80
118
 
119
+ /**
120
+ * @param {string} by
121
+ * @param {CodeceptJS.ILocator} locator
122
+ * @param {*} [context]
123
+ * @return {?Node}
124
+ */
81
125
  codeceptjs.findElement = function (by, locator, context) {
82
126
  return this.findElements(by, locator, context)[0] || null;
83
127
  };
84
128
 
85
129
  // actions
130
+ /**
131
+ * @param {number} el
132
+ * @return {boolean}
133
+ */
86
134
  codeceptjs.clickEl = function (el) {
87
135
  if (document.activeElement instanceof HTMLElement) {
88
136
  document.activeElement.blur();
@@ -92,6 +140,7 @@ if (!window.codeceptjs) {
92
140
  return this.fetchElement(el).dispatchEvent(event);
93
141
  };
94
142
 
143
+ /** @param {number} el */
95
144
  codeceptjs.doubleClickEl = function (el) {
96
145
  if (document.activeElement instanceof HTMLElement) {
97
146
  document.activeElement.blur();
@@ -101,6 +150,11 @@ if (!window.codeceptjs) {
101
150
  this.fetchElement(el).dispatchEvent(event);
102
151
  };
103
152
 
153
+ /**
154
+ * @param {number} el
155
+ * @param {number | undefined} x
156
+ * @param {number | undefined} y
157
+ */
104
158
  codeceptjs.hoverEl = function (el, x, y) {
105
159
  if (document.activeElement instanceof HTMLElement) {
106
160
  document.activeElement.blur();
@@ -118,7 +172,7 @@ if (!window.codeceptjs) {
118
172
  this.fetchElement(el).dispatchEvent(event);
119
173
  };
120
174
 
121
-
175
+ /** @param {number} el */
122
176
  codeceptjs.rightClickEl = function (el) {
123
177
  const event = new MouseEvent('contextmenu', {
124
178
  bubbles: true,
@@ -130,6 +184,10 @@ if (!window.codeceptjs) {
130
184
  this.fetchElement(el).dispatchEvent(event);
131
185
  };
132
186
 
187
+ /**
188
+ * @param {number} el
189
+ * @return {boolean | undefined}
190
+ */
133
191
  codeceptjs.checkEl = function (el) {
134
192
  const element = this.fetchElement(el);
135
193
  const event = document.createEvent('HTMLEvents');
@@ -139,6 +197,10 @@ if (!window.codeceptjs) {
139
197
  return element.dispatchEvent(event);
140
198
  };
141
199
 
200
+ /**
201
+ * @param {number} el
202
+ * @return {boolean}
203
+ */
142
204
  codeceptjs.unCheckEl = function (el) {
143
205
  const element = this.fetchElement(el);
144
206
  const event = document.createEvent('HTMLEvents');
@@ -0,0 +1,24 @@
1
+ function isElementClickable(elem) {
2
+ if (!elem.getBoundingClientRect || !elem.scrollIntoView || !document.elementFromPoint) {
3
+ return false;
4
+ }
5
+
6
+ const isElementInViewport = (elem) => {
7
+ const rect = elem.getBoundingClientRect();
8
+ const verticleInView = (rect.top <= window.innerHeight) && ((rect.top + rect.height) > 0);
9
+ const horizontalInView = (rect.left <= window.innerWidth) && ((rect.left + rect.width) > 0);
10
+ return horizontalInView && verticleInView;
11
+ };
12
+
13
+ const getOverlappingElement = (elem) => {
14
+ const rect = elem.getBoundingClientRect();
15
+ const x = rect.left + (elem.clientWidth / 2);
16
+ const y = rect.top + (elem.clientHeight / 2);
17
+ return document.elementFromPoint(x, y);
18
+ };
19
+
20
+ const isClickable = elem => elem.disabled !== true && isElementInViewport(elem) && getOverlappingElement(elem) === elem;
21
+ return isClickable(elem);
22
+ }
23
+
24
+ module.exports = isElementClickable;
package/lib/helper.js CHANGED
@@ -21,6 +21,8 @@ class Helper {
21
21
 
22
22
  /**
23
23
  * Abstract method to provide required config options
24
+ * @return {*}
25
+ * @protected
24
26
  */
25
27
  static _config() {
26
28
 
@@ -29,6 +31,8 @@ class Helper {
29
31
  /**
30
32
  * Abstract method to validate config
31
33
  * @param {*} config
34
+ * @returns {*}
35
+ * @protected
32
36
  */
33
37
  _validateConfig(config) {
34
38
  return config;
@@ -36,6 +40,8 @@ class Helper {
36
40
 
37
41
  /**
38
42
  * Sets config for current test
43
+ * @param {*} opts
44
+ * @protected
39
45
  */
40
46
  _setConfig(opts) {
41
47
  this.options = this._validateConfig(opts);
@@ -43,6 +49,7 @@ class Helper {
43
49
 
44
50
  /**
45
51
  * Hook executed before all tests
52
+ * @protected
46
53
  */
47
54
  _init() {
48
55
 
@@ -50,6 +57,7 @@ class Helper {
50
57
 
51
58
  /**
52
59
  * Hook executed before each test.
60
+ * @protected
53
61
  */
54
62
  _before() {
55
63
 
@@ -57,6 +65,7 @@ class Helper {
57
65
 
58
66
  /**
59
67
  * Hook executed after each test
68
+ * @protected
60
69
  */
61
70
  _after() {
62
71
 
@@ -66,7 +75,8 @@ class Helper {
66
75
  * Hook provides a test details
67
76
  * Executed in the very beginning of a test
68
77
  *
69
- * @param {*} test
78
+ * @param {Mocha.Test} test
79
+ * @protected
70
80
  */
71
81
  _test(test) {
72
82
 
@@ -75,7 +85,8 @@ class Helper {
75
85
  /**
76
86
  * Hook executed after each passed test
77
87
  *
78
- * @param {*} test
88
+ * @param {Mocha.Test} test
89
+ * @protected
79
90
  */
80
91
  _passed(test) {
81
92
 
@@ -84,7 +95,8 @@ class Helper {
84
95
  /**
85
96
  * Hook executed after each failed test
86
97
  *
87
- * @param {*} test
98
+ * @param {Mocha.Test} test
99
+ * @protected
88
100
  */
89
101
  _failed(test) {
90
102
 
@@ -93,8 +105,8 @@ class Helper {
93
105
  /**
94
106
  * Hook executed before each step
95
107
  *
96
- * @param {*} step
97
- * @override
108
+ * @param {CodeceptJS.Step} step
109
+ * @protected
98
110
  */
99
111
  _beforeStep(step) {
100
112
 
@@ -103,8 +115,8 @@ class Helper {
103
115
  /**
104
116
  * Hook executed after each step
105
117
  *
106
- * @param {*} step
107
- * @override
118
+ * @param {CodeceptJS.Step} step
119
+ * @protected
108
120
  */
109
121
  _afterStep(step) {
110
122
 
@@ -113,7 +125,8 @@ class Helper {
113
125
  /**
114
126
  * Hook executed before each suite
115
127
  *
116
- * @param {*} suite
128
+ * @param {Mocha.Suite} suite
129
+ * @protected
117
130
  */
118
131
  _beforeSuite(suite) {
119
132
 
@@ -122,7 +135,8 @@ class Helper {
122
135
  /**
123
136
  * Hook executed after each suite
124
137
  *
125
- * @param {*} suite
138
+ * @param {Mocha.Suite} suite
139
+ * @protected
126
140
  */
127
141
  _afterSuite(suite) {
128
142
 
@@ -131,7 +145,8 @@ class Helper {
131
145
  /**
132
146
  * Hook executed after all tests are executed
133
147
  *
134
- * @param {*} suite
148
+ * @param {Mocha.Suite} suite
149
+ * @protected
135
150
  */
136
151
  _finishTest(suite) {
137
152
 
@@ -139,6 +154,9 @@ class Helper {
139
154
 
140
155
  /**
141
156
  * Access another configured helper: `this.helpers['AnotherHelper']`
157
+ *
158
+ * @readonly
159
+ * @type {*}
142
160
  */
143
161
  get helpers() {
144
162
  return container.helpers();
@@ -146,11 +164,17 @@ class Helper {
146
164
 
147
165
  /**
148
166
  * Print debug message to console (outputs only in debug mode)
167
+ *
168
+ * @param {string} msg
149
169
  */
150
170
  debug(msg) {
151
171
  output.debug(msg);
152
172
  }
153
173
 
174
+ /**
175
+ * @param {string} section
176
+ * @param {string} msg
177
+ */
154
178
  debugSection(section, msg) {
155
179
  output.debug(`[${section}] ${msg}`);
156
180
  }
package/lib/history.js CHANGED
@@ -1,8 +1,8 @@
1
+ const colors = require('chalk');
1
2
  const fs = require('fs');
2
3
  const path = require('path');
3
4
 
4
5
  const output = require('./output');
5
- const colors = require('chalk');
6
6
 
7
7
  /**
8
8
  * REPL history records REPL commands and stores them in
package/lib/hooks.js CHANGED
@@ -1,5 +1,6 @@
1
- const getParamNames = require('./utils').getParamNames;
2
1
  const fsPath = require('path');
2
+
3
+ const getParamNames = require('./utils').getParamNames;
3
4
  const fileExists = require('./utils').fileExists;
4
5
  const output = require('./output');
5
6
 
package/lib/index.js CHANGED
@@ -2,19 +2,38 @@
2
2
  * Index file for loading CodeceptJS programmatically.
3
3
  *
4
4
  * Includes Public API objects
5
+ * @alias index
6
+ * @namespace
5
7
  */
6
8
  module.exports = {
9
+ /** @type {typeof CodeceptJS.Codecept} */
7
10
  codecept: require('./codecept'),
11
+ /** @type {typeof CodeceptJS.Codecept} */
12
+ Codecept: require('./codecept'),
13
+ /** @type {typeof CodeceptJS.output} */
8
14
  output: require('./output'),
15
+ /** @type {typeof CodeceptJS.Container} */
9
16
  container: require('./container'),
17
+ /** @type {typeof CodeceptJS.event} */
10
18
  event: require('./event'),
19
+ /** @type {CodeceptJS.recorder} */
11
20
  recorder: require('./recorder'),
21
+ /** @type {typeof CodeceptJS.Config} */
12
22
  config: require('./config'),
23
+ /** @type {CodeceptJS.actor} */
13
24
  actor: require('./actor'),
25
+ /** @type {typeof CodeceptJS.Helper} */
14
26
  helper: require('./helper'),
27
+ /** @type {typeof CodeceptJS.Helper} */
28
+ Helper: require('./helper'),
29
+ /** @type {typeof CodeceptJS.pause} */
15
30
  pause: require('./pause'),
31
+ /** @type {typeof CodeceptJS.within} */
16
32
  within: require('./within'),
33
+ /** @type {typeof CodeceptJS.DataTable} */
17
34
  dataTable: require('./data/table'),
35
+ /** @type {typeof CodeceptJS.store} */
18
36
  store: require('./store'),
37
+ /** @type {typeof CodeceptJS.Locator} */
19
38
  locator: require('./locator'),
20
39
  };
@@ -8,6 +8,10 @@ let steps = {};
8
8
 
9
9
  const STACK_POSITION = 2;
10
10
 
11
+ /**
12
+ * @param {*} step
13
+ * @param {*} fn
14
+ */
11
15
  const addStep = (step, fn) => {
12
16
  const stack = (new Error()).stack;
13
17
  steps[step] = fn;
@@ -1,3 +1,4 @@
1
+ /** @class */
1
2
  class FeatureConfig {
2
3
  constructor(suite) {
3
4
  this.suite = suite;
@@ -6,7 +7,8 @@ class FeatureConfig {
6
7
  /**
7
8
  * Retry this suite for x times
8
9
  *
9
- * @param {*} retries
10
+ * @param {number} retries
11
+ * @returns {this}
10
12
  */
11
13
  retry(retries) {
12
14
  this.suite.retries(retries);
@@ -15,7 +17,8 @@ class FeatureConfig {
15
17
 
16
18
  /**
17
19
  * Set timeout for this suite
18
- * @param {*} timeout
20
+ * @param {number} timeout
21
+ * @returns {this}
19
22
  */
20
23
  timeout(timeout) {
21
24
  this.suite.timeout(timeout);
@@ -25,6 +28,9 @@ class FeatureConfig {
25
28
  /**
26
29
  * Configures a helper.
27
30
  * Helper name can be omitted and values will be applied to first helper.
31
+ * @param {string | Object<string, *>} helper
32
+ * @param {Object<string, *>} [obj]
33
+ * @returns {this}
28
34
  */
29
35
  config(helper, obj) {
30
36
  if (!obj) {
@@ -44,7 +50,8 @@ class FeatureConfig {
44
50
 
45
51
  /**
46
52
  * Append a tag name to scenario title
47
- * @param {*} tagName
53
+ * @param {string} tagName
54
+ * @returns {this}
48
55
  */
49
56
  tag(tagName) {
50
57
  if (tagName[0] !== '@') {
@@ -6,6 +6,7 @@ const { isAsyncFunction } = require('../utils');
6
6
  const event = require('../event');
7
7
  const scenario = require('../scenario');
8
8
  const Step = require('../step');
9
+ const DataTableArgument = require('../data/dataTableArgument');
9
10
 
10
11
  const parser = new Parser();
11
12
  parser.stopAtFirstError = false;
@@ -36,6 +37,9 @@ module.exports = (text) => {
36
37
  };
37
38
  const fn = matchStep(step.text);
38
39
  if (step.argument) {
40
+ step.argument.parse = () => {
41
+ return new DataTableArgument(step.argument);
42
+ };
39
43
  fn.params.push(step.argument);
40
44
  if (step.argument.type === 'DataTable') metaStep.comment = `\n${transformTable(step.argument)}`;
41
45
  if (step.argument.content) metaStep.comment = `\n${step.argument.content}`;
@@ -65,7 +69,7 @@ module.exports = (text) => {
65
69
  const value = example.cells[index].value;
66
70
  current[placeholder] = value;
67
71
  exampleSteps = exampleSteps.map((step) => {
68
- step = Object.assign({}, step);
72
+ step = { ...step };
69
73
  step.text = step.text.replace(`<${placeholder}>`, value);
70
74
  return step;
71
75
  });
@@ -102,7 +106,7 @@ function addExampleInTable(exampleSteps, placeholders) {
102
106
  const steps = JSON.parse(JSON.stringify(exampleSteps));
103
107
  for (const placeholder in placeholders) {
104
108
  steps.map((step) => {
105
- step = Object.assign({}, step);
109
+ step = { ...step };
106
110
  if (step.argument && step.argument.type === 'DataTable') {
107
111
  for (const id in step.argument.rows) {
108
112
  const cells = step.argument.rows[id].cells;
@@ -1,3 +1,4 @@
1
+ /** @class */
1
2
  class ScenarioConfig {
2
3
  constructor(test) {
3
4
  this.test = test;
@@ -8,6 +9,7 @@ class ScenarioConfig {
8
9
  * Can pass an Error object or regex matching expected message.
9
10
  *
10
11
  * @param {*} err
12
+ * @returns {this}
11
13
  */
12
14
  throws(err) {
13
15
  this.test.throws = err;
@@ -19,7 +21,7 @@ class ScenarioConfig {
19
21
  * If test passes - throws an error.
20
22
  * Can pass an Error object or regex matching expected message.
21
23
  *
22
- * @param {*} err
24
+ * @returns {this}
23
25
  */
24
26
  fails() {
25
27
  this.test.throws = new Error();
@@ -29,7 +31,8 @@ class ScenarioConfig {
29
31
  /**
30
32
  * Retry this test for x times
31
33
  *
32
- * @param {*} retries
34
+ * @param {number} retries
35
+ * @returns {this}
33
36
  */
34
37
  retry(retries) {
35
38
  this.test.retries(retries);
@@ -38,7 +41,8 @@ class ScenarioConfig {
38
41
 
39
42
  /**
40
43
  * Set timeout for this test
41
- * @param {*} timeout
44
+ * @param {number} timeout
45
+ * @returns {this}
42
46
  */
43
47
  timeout(timeout) {
44
48
  this.test.timeout(timeout);
@@ -47,7 +51,8 @@ class ScenarioConfig {
47
51
 
48
52
  /**
49
53
  * Pass in additional objects to inject into test
50
- * @param {*} obj
54
+ * @param {Object<string, any>} obj
55
+ * @returns {this}
51
56
  */
52
57
  inject(obj) {
53
58
  this.test.inject = obj;
@@ -57,6 +62,9 @@ class ScenarioConfig {
57
62
  /**
58
63
  * Configures a helper.
59
64
  * Helper name can be omitted and values will be applied to first helper.
65
+ * @param {string | Object<string, any>} helper
66
+ * @param {Object<string, any>} [obj]
67
+ * @returns {this}
60
68
  */
61
69
  async config(helper, obj) {
62
70
  if (!obj) {
@@ -75,7 +83,8 @@ class ScenarioConfig {
75
83
 
76
84
  /**
77
85
  * Append a tag name to scenario title
78
- * @param {*} tagName
86
+ * @param {string} tagName
87
+ * @returns {this}
79
88
  */
80
89
  tag(tagName) {
81
90
  if (tagName[0] !== '@') tagName = `@${tagName}`;
@@ -86,12 +95,14 @@ class ScenarioConfig {
86
95
 
87
96
  /**
88
97
  * Dynamically injects dependencies, see https://codecept.io/pageobjects/#dynamic-injection
89
- * @param {*} dependencies
98
+ * @param {Object<string, *>} dependencies
99
+ * @returns {this}
90
100
  */
91
101
  injectDependencies(dependencies) {
92
102
  Object.keys(dependencies).forEach((key) => {
93
103
  this.test.inject[key] = dependencies[key];
94
104
  });
105
+ return this;
95
106
  }
96
107
  }
97
108
 
@@ -15,7 +15,7 @@ module.exports = function () {
15
15
  function enableDynamicConfigFor(type) {
16
16
  event.dispatcher.on(event[type].before, (context = {}) => {
17
17
  function updateHelperConfig(helper, config) {
18
- const oldConfig = Object.assign({}, helper.options);
18
+ const oldConfig = { ...helper.options };
19
19
  try {
20
20
  helper._setConfig(deepMerge(deepClone(oldConfig), config));
21
21
  debug(`[${ucfirst(type)} Config] ${helper.constructor.name} ${JSON.stringify(config)}`);
@@ -23,4 +23,10 @@ module.exports = function () {
23
23
  process.exitCode = 1;
24
24
  }
25
25
  });
26
+
27
+ process.on('beforeExit', (code) => {
28
+ if (code) {
29
+ process.exit(code);
30
+ }
31
+ });
26
32
  };
@@ -61,4 +61,3 @@ module.exports = function () {
61
61
  currentTest.steps.push(step);
62
62
  });
63
63
  };
64
-
@@ -34,4 +34,3 @@ module.exports = function () {
34
34
  test.err = err;
35
35
  });
36
36
  };
37
-