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
package/lib/event.js CHANGED
@@ -3,8 +3,28 @@ const events = require('events');
3
3
  const dispatcher = new events.EventEmitter();
4
4
  const log = require('./output').log;
5
5
 
6
+ /**
7
+ * @namespace
8
+ * @alias event
9
+ */
6
10
  module.exports = {
11
+ /**
12
+ * @type {NodeJS.EventEmitter}
13
+ * @constant
14
+ * @inner
15
+ */
7
16
  dispatcher,
17
+ /**
18
+ * @type {object}
19
+ * @constant
20
+ * @inner
21
+ * @property {'test.start'} started
22
+ * @property {'test.before'} before
23
+ * @property {'test.after'} after
24
+ * @property {'test.passed'} passed
25
+ * @property {'test.failed'} failed
26
+ * @property {'test.finish'} finished
27
+ */
8
28
  test: {
9
29
  started: 'test.start', // sync
10
30
  before: 'test.before', // async
@@ -13,15 +33,40 @@ module.exports = {
13
33
  failed: 'test.failed', // sync
14
34
  finished: 'test.finish', // sync
15
35
  },
36
+ /**
37
+ * @type {object}
38
+ * @constant
39
+ * @inner
40
+ * @property {'suite.before'} before
41
+ * @property {'suite.after'} after
42
+ */
16
43
  suite: {
17
44
  before: 'suite.before',
18
45
  after: 'suite.after',
19
46
  },
47
+ /**
48
+ * @type {object}
49
+ * @constant
50
+ * @inner
51
+ * @property {'hook.start'} started
52
+ * @property {'hook.passed'} passed
53
+ */
20
54
  hook: {
21
55
  started: 'hook.start',
22
56
  passed: 'hook.passed',
23
57
  failed: 'hook.failed',
24
58
  },
59
+ /**
60
+ * @type {object}
61
+ * @constant
62
+ * @inner
63
+ * @property {'step.start'} started
64
+ * @property {'step.before'} before
65
+ * @property {'step.after'} after
66
+ * @property {'step.passed'} passed
67
+ * @property {'step.failed'} failed
68
+ * @property {'step.finish'} finished
69
+ */
25
70
  step: {
26
71
  before: 'step.before', // async
27
72
  after: 'step.after', // async
@@ -31,16 +76,35 @@ module.exports = {
31
76
  finished: 'step.finish', // sync
32
77
  comment: 'step.comment',
33
78
  },
79
+ /**
80
+ * @type {object}
81
+ * @constant
82
+ * @inner
83
+ * @property {'global.before'} before
84
+ * @property {'global.after'} after
85
+ * @property {'global.result'} result
86
+ */
34
87
  all: {
35
88
  before: 'global.before',
36
89
  after: 'global.after',
37
90
  result: 'global.result',
38
91
  },
92
+ /**
93
+ * @type {object}
94
+ * @constant
95
+ * @inner
96
+ * @property {'multiple.before'} before
97
+ * @property {'multiple.after'} after
98
+ */
39
99
  multiple: {
40
100
  before: 'multiple.before',
41
101
  after: 'multiple.after',
42
102
  },
43
103
 
104
+ /**
105
+ * @param {string} event
106
+ * @param {*} param
107
+ */
44
108
  emit(event, param) {
45
109
  let msg = `Emitted | ${event}`;
46
110
  if (param && param.toString()) {
@@ -55,7 +119,7 @@ module.exports = {
55
119
  }
56
120
  },
57
121
 
58
- // for testing only!
122
+ /** for testing only! */
59
123
  cleanDispatcher: () => {
60
124
  let event;
61
125
  for (event in this.test) {
@@ -1,11 +1,13 @@
1
1
  let webdriverio;
2
2
  let wdioV4;
3
3
  let SCREEN_SIZE;
4
+
5
+ const fs = require('fs');
6
+ const requireg = require('requireg');
7
+
4
8
  const Webdriver = require('./WebDriver');
5
9
  const AssertionFailedError = require('../assert/error');
6
10
  const truth = require('../assert/truth').truth;
7
- const requireg = require('requireg');
8
- const fs = require('fs');
9
11
  const recorder = require('../recorder');
10
12
  const Locator = require('../locator');
11
13
  const ConnectionRefused = require('./errors/ConnectionRefused');
@@ -249,7 +251,8 @@ class Appium extends Webdriver {
249
251
  width: res.value[0],
250
252
  height: res.value[1],
251
253
  });
252
- } else if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0 && !this.platform) {
254
+ }
255
+ if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0 && !this.platform) {
253
256
  const dimensions = this.options.windowSize.split('x');
254
257
  await this.browser.windowHandleSize({
255
258
  width: dimensions[0],
@@ -435,7 +438,7 @@ class Appium extends Webdriver {
435
438
  * I.seeAppIsInstalled("com.example.android.apis");
436
439
  * ```
437
440
  *
438
- * @param bundleId String ID of bundled app
441
+ * @param {string} bundleId String ID of bundled app
439
442
  *
440
443
  * Appium: support only Android
441
444
  */
@@ -452,7 +455,7 @@ class Appium extends Webdriver {
452
455
  * I.seeAppIsNotInstalled("com.example.android.apis");
453
456
  * ```
454
457
  *
455
- * @param bundleId String ID of bundled app
458
+ * @param {string} bundleId String ID of bundled app
456
459
  *
457
460
  * Appium: support only Android
458
461
  */
@@ -468,7 +471,7 @@ class Appium extends Webdriver {
468
471
  * ```js
469
472
  * I.installApp('/path/to/file.apk');
470
473
  * ```
471
- * @param path path to apk file
474
+ * @param {string} path path to apk file
472
475
  *
473
476
  * Appium: support only Android
474
477
  */
@@ -483,7 +486,8 @@ class Appium extends Webdriver {
483
486
  * ```js
484
487
  * I.removeApp('appName', 'com.example.android.apis');
485
488
  * ```
486
- * @param bundleId String ID of bundle
489
+ * @param {string} appId
490
+ * @param {string} bundleId String ID of bundle
487
491
  *
488
492
  * Appium: support only Android
489
493
  */
@@ -507,6 +511,7 @@ class Appium extends Webdriver {
507
511
  * ```js
508
512
  * I.seeCurrentActivityIs(".HomeScreenActivity")
509
513
  * ```
514
+ * @param {string} currentActivity
510
515
  *
511
516
  * Appium: support only Android
512
517
  */
@@ -554,7 +559,7 @@ class Appium extends Webdriver {
554
559
  * I.seeOrientationIs('LANDSCAPE')
555
560
  * ```
556
561
  *
557
- * @param orientation LANDSCAPE or PORTRAIT
562
+ * @param {'LANDSCAPE'|'PORTRAIT'} orientation LANDSCAPE or PORTRAIT
558
563
  *
559
564
  * Appium: support Android and iOS
560
565
  */
@@ -584,7 +589,7 @@ class Appium extends Webdriver {
584
589
  * I.setOrientation('LANDSCAPE')
585
590
  * ```
586
591
  *
587
- * @param orientation LANDSCAPE or PORTRAIT
592
+ * @param {'LANDSCAPE'|'PORTRAIT'} orientation LANDSCAPE or PORTRAIT
588
593
  *
589
594
  * Appium: support Android and iOS
590
595
  */
@@ -700,7 +705,7 @@ class Appium extends Webdriver {
700
705
  /**
701
706
  * Switch to the specified context.
702
707
  *
703
- * @param context the context to switch to
708
+ * @param {*} context the context to switch to
704
709
 
705
710
  */
706
711
  async _switchToContext(context) {
@@ -799,7 +804,7 @@ class Appium extends Webdriver {
799
804
  * I.setSettings({cyberdelia: 'open'});
800
805
  * ```
801
806
  *
802
- * @param settings object
807
+ * @param {object} settings object
803
808
  *
804
809
  * Appium: support Android and iOS
805
810
  */
@@ -820,7 +825,7 @@ class Appium extends Webdriver {
820
825
  * I.hideDeviceKeyboard('pressKey', 'Done');
821
826
  * ```
822
827
  *
823
- * @param strategy desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
828
+ * @param {'tapOutside' | 'pressKey'} strategy desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
824
829
  *
825
830
  * Appium: support Android and iOS
826
831
  */
@@ -838,7 +843,7 @@ class Appium extends Webdriver {
838
843
  * I.sendDeviceKeyEvent(3);
839
844
  * ```
840
845
  *
841
- * @param keyValue Device specific key value
846
+ * @param {number} keyValue Device specific key value
842
847
  *
843
848
  * Appium: support only Android
844
849
  */
@@ -912,10 +917,10 @@ class Appium extends Webdriver {
912
917
  *
913
918
  * [See complete reference](http://webdriver.io/api/mobile/swipe.html)
914
919
  *
915
- * @param locator
916
- * @param xoffset
917
- * @param yoffset
918
- * @param speed (optional), 1000 by default
920
+ * @param {CodeceptJS.LocatorOrString} locator
921
+ * @param {number} xoffset
922
+ * @param {number} yoffset
923
+ * @param {number} [speed=1000] (optional), 1000 by default
919
924
  *
920
925
  * Appium: support Android and iOS
921
926
  */
@@ -933,8 +938,8 @@ class Appium extends Webdriver {
933
938
  * I.performswipe(100,200);
934
939
  * ```
935
940
  *
936
- * @param from
937
- * @param to
941
+ * @param {number} from
942
+ * @param {number} to
938
943
  *
939
944
  * Appium: support Android and iOS
940
945
  */
@@ -964,9 +969,9 @@ class Appium extends Webdriver {
964
969
  * I.swipeDown(locator, 1200, 1000); // set offset and speed
965
970
  * ```
966
971
  *
967
- * @param locator
968
- * @param yoffset (optional)
969
- * @param speed (optional), 1000 by default
972
+ * @param {CodeceptJS.LocatorOrString} locator
973
+ * @param {number} [yoffset] (optional)
974
+ * @param {number} [speed=1000] (optional), 1000 by default
970
975
  *
971
976
  * Appium: support Android and iOS
972
977
  */
@@ -992,9 +997,9 @@ class Appium extends Webdriver {
992
997
  * I.swipeLeft(locator, 1200, 1000); // set offset and speed
993
998
  * ```
994
999
  *
995
- * @param locator
996
- * @param xoffset (optional)
997
- * @param speed (optional), 1000 by default
1000
+ * @param {CodeceptJS.LocatorOrString} locator
1001
+ * @param {number} [xoffset] (optional)
1002
+ * @param {number} [speed=1000] (optional), 1000 by default
998
1003
  *
999
1004
  * Appium: support Android and iOS
1000
1005
  */
@@ -1018,9 +1023,9 @@ class Appium extends Webdriver {
1018
1023
  * I.swipeRight(locator, 1200, 1000); // set offset and speed
1019
1024
  * ```
1020
1025
  *
1021
- * @param locator
1022
- * @param xoffset (optional)
1023
- * @param speed (optional), 1000 by default
1026
+ * @param {CodeceptJS.LocatorOrString} locator
1027
+ * @param {number} [xoffset] (optional)
1028
+ * @param {number} [speed=1000] (optional), 1000 by default
1024
1029
  *
1025
1030
  * Appium: support Android and iOS
1026
1031
  */
@@ -1044,9 +1049,9 @@ class Appium extends Webdriver {
1044
1049
  * I.swipeUp(locator, 1200, 1000); // set offset and speed
1045
1050
  * ```
1046
1051
  *
1047
- * @param locator
1048
- * @param yoffset (optional)
1049
- * @param speed (optional), 1000 by default
1052
+ * @param {CodeceptJS.LocatorOrString} locator
1053
+ * @param {number} [yoffset] (optional)
1054
+ * @param {number} [speed=1000] (optional), 1000 by default
1050
1055
  *
1051
1056
  * Appium: support Android and iOS
1052
1057
  */
@@ -1074,12 +1079,12 @@ class Appium extends Webdriver {
1074
1079
  * 500);
1075
1080
  * ```
1076
1081
  *
1077
- * @param searchableLocator
1078
- * @param scrollLocator
1079
- * @param direction
1080
- * @param timeout
1081
- * @param offset
1082
- * @param speed
1082
+ * @param {string} searchableLocator
1083
+ * @param {string} scrollLocator
1084
+ * @param {string} direction
1085
+ * @param {number} timeout
1086
+ * @param {number} offset
1087
+ * @param {number} speed
1083
1088
  *
1084
1089
  * Appium: support Android and iOS
1085
1090
  */
@@ -1351,6 +1356,15 @@ class Appium extends Webdriver {
1351
1356
  return super.grabValueFrom(parseLocator.call(this, locator));
1352
1357
  }
1353
1358
 
1359
+ /**
1360
+ * {{> scrollIntoView }}
1361
+ *
1362
+ * Supported only for web testing
1363
+ */
1364
+ async scrollIntoView(locator, scrollIntoViewOptions) {
1365
+ if (this.isWeb) return super.scrollIntoView(locator, scrollIntoViewOptions);
1366
+ }
1367
+
1354
1368
  /**
1355
1369
  * {{> seeCheckboxIsChecked }}
1356
1370
  *
@@ -1390,7 +1404,7 @@ class Appium extends Webdriver {
1390
1404
  /**
1391
1405
  * {{> selectOption }}
1392
1406
  *
1393
- * * Supported on only for web testing!
1407
+ * Supported only for web testing
1394
1408
  */
1395
1409
  async selectOption(select, option) {
1396
1410
  if (this.isWeb) return super.selectOption(select, option);
@@ -1,10 +1,11 @@
1
+ const assert = require('assert');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
1
5
  const Helper = require('../helper');
2
6
  const fileExists = require('../utils').fileExists;
3
7
  const fileIncludes = require('../assert/include').fileIncludes;
4
8
  const fileEquals = require('../assert/equal').fileEquals;
5
- const assert = require('assert');
6
- const path = require('path');
7
- const fs = require('fs');
8
9
 
9
10
  /**
10
11
  * Helper for testing filesystem.
@@ -33,6 +34,7 @@ class FileSystem extends Helper {
33
34
  /**
34
35
  * Enters a directory In local filesystem.
35
36
  * Starts from a current directory
37
+ * @param {string} openPath
36
38
  */
37
39
  amInPath(openPath) {
38
40
  this.dir = path.join(global.codecept_dir, openPath);
@@ -41,6 +43,8 @@ class FileSystem extends Helper {
41
43
 
42
44
  /**
43
45
  * Writes test to file
46
+ * @param {string} name
47
+ * @param {string} text
44
48
  */
45
49
  writeToFile(name, text) {
46
50
  fs.writeFileSync(path.join(this.dir, name), text);
@@ -48,6 +52,7 @@ class FileSystem extends Helper {
48
52
 
49
53
  /**
50
54
  * Checks that file exists
55
+ * @param {string} name
51
56
  */
52
57
  seeFile(name) {
53
58
  this.file = path.join(this.dir, name);
@@ -55,8 +60,27 @@ class FileSystem extends Helper {
55
60
  assert.ok(fileExists(this.file), `File ${name} not found in ${this.dir}`);
56
61
  }
57
62
 
63
+ /**
64
+ * Checks that file with a name including given text exists in the current directory.
65
+ *
66
+ *```js
67
+ * I.handleDownloads();
68
+ * I.click('Download as PDF');
69
+ * I.amInPath('output/downloads');
70
+ * I.seeFileNameMatching('.pdf');
71
+ * ```
72
+ */
73
+ seeFileNameMatching(text) {
74
+ assert.ok(
75
+ this.grabFileNames().some(file => file.includes(text)),
76
+ `File name which contains ${text} not found in ${this.dir}`,
77
+ );
78
+ }
79
+
58
80
  /**
59
81
  * Checks that file found by `seeFile` includes a text.
82
+ * @param {string} text
83
+ * @param {string} encoding
60
84
  */
61
85
  seeInThisFile(text, encoding) {
62
86
  const content = getFileContents(this.file, encoding);
@@ -65,6 +89,8 @@ class FileSystem extends Helper {
65
89
 
66
90
  /**
67
91
  * Checks that file found by `seeFile` doesn't include text.
92
+ * @param {string} text
93
+ * @param {string} encoding
68
94
  */
69
95
  dontSeeInThisFile(text, encoding) {
70
96
  const content = getFileContents(this.file, encoding);
@@ -73,6 +99,8 @@ class FileSystem extends Helper {
73
99
 
74
100
  /**
75
101
  * Checks that contents of file found by `seeFile` equal to text.
102
+ * @param {string} text
103
+ * @param {string} encoding
76
104
  */
77
105
  seeFileContentsEqual(text, encoding) {
78
106
  const content = getFileContents(this.file, encoding);
@@ -81,11 +109,28 @@ class FileSystem extends Helper {
81
109
 
82
110
  /**
83
111
  * Checks that contents of file found by `seeFile` doesn't equal to text.
112
+ * @param {string} text
113
+ * @param {string} encoding
84
114
  */
85
115
  dontSeeFileContentsEqual(text, encoding) {
86
116
  const content = getFileContents(this.file, encoding);
87
117
  fileEquals(this.file).negate(text, content);
88
118
  }
119
+
120
+ /**
121
+ * Returns file names in current directory.
122
+ *
123
+ * ```js
124
+ * I.handleDownloads();
125
+ * I.click('Download Files');
126
+ * I.amInPath('output/downloads');
127
+ * const downloadedFileNames = I.grabFileNames();
128
+ * ```
129
+ */
130
+ grabFileNames() {
131
+ return fs.readdirSync(this.dir)
132
+ .filter(item => !fs.lstatSync(path.join(this.dir, item)).isDirectory());
133
+ }
89
134
  }
90
135
 
91
136
  function getFileContents(file, encoding) {
@@ -1,6 +1,7 @@
1
- const Helper = require('../helper');
2
1
  const requireg = require('requireg');
3
2
 
3
+ const Helper = require('../helper');
4
+
4
5
  let axios = requireg('axios');
5
6
  let headers = {};
6
7
 
@@ -49,7 +50,7 @@ class GraphQL extends Helper {
49
50
  endpoint: '',
50
51
  };
51
52
  this.options = Object.assign(this.options, config);
52
- headers = Object.assign({}, this.options.defaultHeaders);
53
+ headers = { ...this.options.defaultHeaders };
53
54
  axios.defaults.headers = this.options.defaultHeaders;
54
55
  }
55
56
 
@@ -1,5 +1,6 @@
1
1
  const path = require('path');
2
2
  const requireg = require('requireg');
3
+
3
4
  const Helper = require('../helper');
4
5
  const GraphQL = require('./GraphQL');
5
6
 
@@ -1,10 +1,11 @@
1
1
  let addMochawesomeContext;
2
2
  let currentTest;
3
3
  let currentSuite;
4
+
5
+ const requireg = require('requireg');
6
+
4
7
  const Helper = require('../helper');
5
8
  const clearString = require('../utils').clearString;
6
- const requireg = require('requireg');
7
- const path = require('path');
8
9
 
9
10
 
10
11
  class Mochawesome extends Helper {
@@ -1,5 +1,6 @@
1
- const Helper = require('../helper');
2
1
  const requireg = require('requireg');
2
+
3
+ const Helper = require('../helper');
3
4
  const { appendBaseUrl } = require('../utils');
4
5
  const pollyWebDriver = require('./clientscripts/PollyWebDriverExt');
5
6
 
@@ -32,7 +33,22 @@ let PollyJS;
32
33
  * MockRequest: {}
33
34
  * }
34
35
  * ```
35
- * The same can be done when using WebDriver helper..
36
+ *
37
+ * > Partially works with WebDriver helper
38
+ *
39
+ * [Polly config options](https://netflix.github.io/pollyjs/#/configuration?id=configuration) can be passed as well:
40
+ *
41
+ * ```js
42
+ * // enable replay mode
43
+ * helpers: {
44
+ * Puppeteer: {
45
+ * // regular Puppeteer config here
46
+ * },
47
+ * MockRequest: {
48
+ * mode: 'replay',
49
+ * },
50
+ * }
51
+ * ```
36
52
  *
37
53
  * ### Usage
38
54
  *
@@ -101,13 +117,15 @@ class MockRequest extends Helper {
101
117
  }
102
118
  await page.setRequestInterception(true);
103
119
 
104
- this.polly = new PollyJS(title, {
120
+ const defaultConfig = {
105
121
  mode: 'passthrough',
106
122
  adapters: ['puppeteer'],
107
123
  adapterOptions: {
108
124
  puppeteer: { page },
109
125
  },
110
- });
126
+ };
127
+
128
+ this.polly = new PollyJS(title, { ...defaultConfig, ...this.options });
111
129
  }
112
130
 
113
131
  /**
@@ -140,7 +158,7 @@ class MockRequest extends Helper {
140
158
  * I.mockRequest('GET', ['/secrets', '/v2/secrets'], 403);
141
159
  * ```
142
160
  * @param {string} method request method. Can be `GET`, `POST`, `PUT`, etc or `ANY`.
143
- * @param {string|array} oneOrMoreUrls url(s) to mock. Can be exact URL, a pattern, or an array of URLs.
161
+ * @param {string|string[]} oneOrMoreUrls url(s) to mock. Can be exact URL, a pattern, or an array of URLs.
144
162
  * @param {number|string|object} dataOrStatusCode status code when number provided. A response body otherwise
145
163
  * @param {string|object} additionalData response body when a status code is set by previous parameter.
146
164
  *
@@ -1,4 +1,7 @@
1
+ const path = require('path');
1
2
  const requireg = require('requireg');
3
+ const urlResolve = require('url').resolve;
4
+
2
5
  const Helper = require('../helper');
3
6
  const stringIncludes = require('../assert/include').includes;
4
7
  const urlEquals = require('../assert/equal').urlEquals;
@@ -6,9 +9,7 @@ const equals = require('../assert/equal').equals;
6
9
  const empty = require('../assert/empty').empty;
7
10
  const truth = require('../assert/truth').truth;
8
11
  const Locator = require('../locator');
9
- const path = require('path');
10
12
  const ElementNotFound = require('./errors/ElementNotFound');
11
- const urlResolve = require('url').resolve;
12
13
  const {
13
14
  xpathLocator,
14
15
  fileExists,
@@ -396,7 +397,7 @@ class Nightmare extends Helper {
396
397
 
397
398
  /**
398
399
  * {{> amOnPage }}
399
- * @param headers {object} list of request headers can be passed
400
+ * @param {?object} headers list of request headers can be passed
400
401
  *
401
402
  */
402
403
  async amOnPage(url, headers = null) {
@@ -760,8 +761,6 @@ class Nightmare extends Helper {
760
761
  * {{> attachFile }}
761
762
  *
762
763
  * Doesn't work if the Chromium DevTools panel is open (as Chromium allows only one attachment to the debugger at a time. [See more](https://github.com/rosshinkley/nightmare-upload#important-note-about-setting-file-upload-inputs))
763
- *
764
- * @param locator CSS locator (XPath not allowed)
765
764
  */
766
765
  async attachFile(locator, pathToFile) {
767
766
  const file = path.join(global.codecept_dir, pathToFile);
@@ -915,7 +914,7 @@ class Nightmare extends Helper {
915
914
  /**
916
915
  * {{> grabCookie }}
917
916
  *
918
- * @returns Promise<object> Cookie in JSON format. If name not passed returns all cookies for this domain.
917
+ * Cookie in JSON format. If name not passed returns all cookies for this domain.
919
918
  *
920
919
  * Multiple cookies can be received by passing query object `I.grabCookie({ secure: true});`. If you'd like get all cookies for all urls, use: `.grabCookie({ url: null }).`
921
920
  */
@@ -4,7 +4,9 @@ let Button;
4
4
  let ProtractorBy;
5
5
  let ProtractorExpectedConditions;
6
6
 
7
+ const path = require('path');
7
8
  const requireg = require('requireg');
9
+
8
10
  const Helper = require('../helper');
9
11
  const stringIncludes = require('../assert/include').includes;
10
12
  const { urlEquals, equals } = require('../assert/equal');
@@ -23,7 +25,6 @@ const {
23
25
  const ElementNotFound = require('./errors/ElementNotFound');
24
26
  const ConnectionRefused = require('./errors/ConnectionRefused');
25
27
  const Locator = require('../locator');
26
- const path = require('path');
27
28
 
28
29
  let withinStore = {};
29
30
  let Runner;
@@ -99,7 +100,7 @@ let Runner;
99
100
  * "browser": "chrome",
100
101
  * "capabilities": {
101
102
  * "chromeOptions": {
102
- * "args": [ "--headless", "--disable-gpu", "--window-size=800,600" ]
103
+ * "args": [ "--headless", "--disable-gpu", "--no-sandbox" ]
103
104
  * }
104
105
  * }
105
106
  * }
@@ -508,11 +509,7 @@ class Protractor extends Helper {
508
509
  }
509
510
 
510
511
  /**
511
- * Checks that text is equal to provided one.
512
- *
513
- * ```js
514
- * I.seeTextEquals('text', 'h1');
515
- * ```
512
+ * {{> seeTextEquals }}
516
513
  */
517
514
  async seeTextEquals(text, context = null) {
518
515
  return proceedSee.call(this, 'assert', text, context, true);
@@ -757,6 +754,7 @@ class Protractor extends Helper {
757
754
  }
758
755
  return array.length === 1 ? array[0] : array;
759
756
  }
757
+
760
758
  /**
761
759
  * {{> seeInTitle }}
762
760
  */
@@ -1235,7 +1233,8 @@ class Protractor extends Helper {
1235
1233
  async switchTo(locator) {
1236
1234
  if (Number.isInteger(locator)) {
1237
1235
  return this.browser.switchTo().frame(locator);
1238
- } else if (!locator) {
1236
+ }
1237
+ if (!locator) {
1239
1238
  return this.browser.switchTo().frame(null);
1240
1239
  }
1241
1240