codeceptjs 4.0.0-beta.3 → 4.0.0-beta.5

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 (155) hide show
  1. package/README.md +134 -119
  2. package/bin/codecept.js +12 -2
  3. package/bin/test-server.js +53 -0
  4. package/docs/webapi/clearCookie.mustache +1 -1
  5. package/lib/actor.js +66 -102
  6. package/lib/ai.js +130 -121
  7. package/lib/assert/empty.js +3 -5
  8. package/lib/assert/equal.js +4 -7
  9. package/lib/assert/include.js +4 -6
  10. package/lib/assert/throws.js +2 -4
  11. package/lib/assert/truth.js +2 -2
  12. package/lib/codecept.js +141 -86
  13. package/lib/command/check.js +201 -0
  14. package/lib/command/configMigrate.js +2 -4
  15. package/lib/command/definitions.js +8 -26
  16. package/lib/command/dryRun.js +30 -35
  17. package/lib/command/generate.js +10 -14
  18. package/lib/command/gherkin/snippets.js +75 -73
  19. package/lib/command/gherkin/steps.js +1 -1
  20. package/lib/command/info.js +42 -8
  21. package/lib/command/init.js +13 -12
  22. package/lib/command/interactive.js +10 -2
  23. package/lib/command/list.js +1 -1
  24. package/lib/command/run-multiple/chunk.js +48 -45
  25. package/lib/command/run-multiple.js +12 -35
  26. package/lib/command/run-workers.js +21 -58
  27. package/lib/command/utils.js +5 -6
  28. package/lib/command/workers/runTests.js +263 -222
  29. package/lib/container.js +386 -238
  30. package/lib/data/context.js +10 -13
  31. package/lib/data/dataScenarioConfig.js +8 -8
  32. package/lib/data/dataTableArgument.js +6 -6
  33. package/lib/data/table.js +5 -11
  34. package/lib/effects.js +223 -0
  35. package/lib/element/WebElement.js +327 -0
  36. package/lib/els.js +158 -0
  37. package/lib/event.js +21 -17
  38. package/lib/heal.js +88 -80
  39. package/lib/helper/AI.js +2 -1
  40. package/lib/helper/ApiDataFactory.js +4 -7
  41. package/lib/helper/Appium.js +50 -57
  42. package/lib/helper/FileSystem.js +3 -3
  43. package/lib/helper/GraphQLDataFactory.js +4 -4
  44. package/lib/helper/JSONResponse.js +75 -37
  45. package/lib/helper/Mochawesome.js +31 -9
  46. package/lib/helper/Nightmare.js +37 -58
  47. package/lib/helper/Playwright.js +267 -272
  48. package/lib/helper/Protractor.js +56 -87
  49. package/lib/helper/Puppeteer.js +247 -264
  50. package/lib/helper/REST.js +29 -17
  51. package/lib/helper/TestCafe.js +22 -47
  52. package/lib/helper/WebDriver.js +157 -368
  53. package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
  54. package/lib/helper/extras/Popup.js +22 -22
  55. package/lib/helper/network/utils.js +1 -1
  56. package/lib/helper/testcafe/testcafe-utils.js +27 -28
  57. package/lib/listener/emptyRun.js +55 -0
  58. package/lib/listener/exit.js +7 -10
  59. package/lib/listener/{retry.js → globalRetry.js} +5 -5
  60. package/lib/listener/globalTimeout.js +165 -0
  61. package/lib/listener/helpers.js +15 -15
  62. package/lib/listener/mocha.js +1 -1
  63. package/lib/listener/result.js +12 -0
  64. package/lib/listener/retryEnhancer.js +85 -0
  65. package/lib/listener/steps.js +32 -18
  66. package/lib/listener/store.js +20 -0
  67. package/lib/locator.js +1 -1
  68. package/lib/mocha/asyncWrapper.js +231 -0
  69. package/lib/{interfaces → mocha}/bdd.js +3 -3
  70. package/lib/mocha/cli.js +308 -0
  71. package/lib/mocha/factory.js +104 -0
  72. package/lib/{interfaces → mocha}/featureConfig.js +32 -12
  73. package/lib/{interfaces → mocha}/gherkin.js +26 -28
  74. package/lib/mocha/hooks.js +112 -0
  75. package/lib/mocha/index.js +12 -0
  76. package/lib/mocha/inject.js +29 -0
  77. package/lib/{interfaces → mocha}/scenarioConfig.js +31 -7
  78. package/lib/mocha/suite.js +82 -0
  79. package/lib/mocha/test.js +181 -0
  80. package/lib/mocha/types.d.ts +42 -0
  81. package/lib/mocha/ui.js +232 -0
  82. package/lib/output.js +93 -65
  83. package/lib/pause.js +160 -138
  84. package/lib/plugin/analyze.js +396 -0
  85. package/lib/plugin/auth.js +435 -0
  86. package/lib/plugin/autoDelay.js +8 -8
  87. package/lib/plugin/autoLogin.js +3 -338
  88. package/lib/plugin/commentStep.js +6 -1
  89. package/lib/plugin/coverage.js +10 -22
  90. package/lib/plugin/customLocator.js +3 -3
  91. package/lib/plugin/customReporter.js +52 -0
  92. package/lib/plugin/eachElement.js +1 -1
  93. package/lib/plugin/fakerTransform.js +1 -1
  94. package/lib/plugin/heal.js +36 -9
  95. package/lib/plugin/htmlReporter.js +1947 -0
  96. package/lib/plugin/pageInfo.js +140 -0
  97. package/lib/plugin/retryFailedStep.js +17 -18
  98. package/lib/plugin/retryTo.js +2 -113
  99. package/lib/plugin/screenshotOnFail.js +17 -58
  100. package/lib/plugin/selenoid.js +15 -35
  101. package/lib/plugin/standardActingHelpers.js +4 -1
  102. package/lib/plugin/stepByStepReport.js +56 -17
  103. package/lib/plugin/stepTimeout.js +5 -12
  104. package/lib/plugin/subtitles.js +4 -4
  105. package/lib/plugin/tryTo.js +3 -102
  106. package/lib/plugin/wdio.js +8 -10
  107. package/lib/recorder.js +155 -124
  108. package/lib/rerun.js +43 -42
  109. package/lib/result.js +161 -0
  110. package/lib/secret.js +1 -2
  111. package/lib/step/base.js +239 -0
  112. package/lib/step/comment.js +10 -0
  113. package/lib/step/config.js +50 -0
  114. package/lib/step/func.js +46 -0
  115. package/lib/step/helper.js +50 -0
  116. package/lib/step/meta.js +99 -0
  117. package/lib/step/record.js +74 -0
  118. package/lib/step/retry.js +11 -0
  119. package/lib/step/section.js +55 -0
  120. package/lib/step.js +21 -332
  121. package/lib/steps.js +50 -0
  122. package/lib/store.js +37 -5
  123. package/lib/template/heal.js +2 -11
  124. package/lib/test-server.js +323 -0
  125. package/lib/timeout.js +66 -0
  126. package/lib/utils.js +351 -218
  127. package/lib/within.js +75 -55
  128. package/lib/workerStorage.js +2 -1
  129. package/lib/workers.js +386 -277
  130. package/package.json +81 -75
  131. package/translations/de-DE.js +5 -3
  132. package/translations/fr-FR.js +5 -4
  133. package/translations/index.js +1 -0
  134. package/translations/it-IT.js +4 -3
  135. package/translations/ja-JP.js +4 -3
  136. package/translations/nl-NL.js +76 -0
  137. package/translations/pl-PL.js +4 -3
  138. package/translations/pt-BR.js +4 -3
  139. package/translations/ru-RU.js +4 -3
  140. package/translations/utils.js +9 -0
  141. package/translations/zh-CN.js +4 -3
  142. package/translations/zh-TW.js +4 -3
  143. package/typings/index.d.ts +197 -187
  144. package/typings/promiseBasedTypes.d.ts +53 -903
  145. package/typings/types.d.ts +372 -1042
  146. package/lib/cli.js +0 -257
  147. package/lib/helper/ExpectHelper.js +0 -391
  148. package/lib/helper/MockServer.js +0 -221
  149. package/lib/helper/SoftExpectHelper.js +0 -381
  150. package/lib/listener/artifacts.js +0 -19
  151. package/lib/listener/timeout.js +0 -109
  152. package/lib/mochaFactory.js +0 -113
  153. package/lib/plugin/debugErrors.js +0 -67
  154. package/lib/scenario.js +0 -224
  155. package/lib/ui.js +0 -236
@@ -117,9 +117,7 @@ class Protractor extends Helper {
117
117
  this.isRunning = false
118
118
  this._setConfig(config)
119
119
 
120
- console.log(
121
- 'Protractor helper is deprecated as well as Protractor itself.\nThis helper will be removed in next major release',
122
- )
120
+ console.log('Protractor helper is deprecated as well as Protractor itself.\nThis helper will be removed in next major release')
123
121
  }
124
122
 
125
123
  _validateConfig(config) {
@@ -152,7 +150,7 @@ class Protractor extends Helper {
152
150
  }
153
151
 
154
152
  async _init() {
155
- process.on('unhandledRejection', (reason) => {
153
+ process.on('unhandledRejection', reason => {
156
154
  if (reason.message.indexOf('ECONNREFUSED') > 0) {
157
155
  this.browser = null
158
156
  }
@@ -288,9 +286,7 @@ class Protractor extends Helper {
288
286
  if (frame) {
289
287
  if (Array.isArray(frame)) {
290
288
  withinStore.frame = frame.join('>')
291
- return this.switchTo(null).then(() =>
292
- frame.reduce((p, frameLocator) => p.then(() => this.switchTo(frameLocator)), Promise.resolve()),
293
- )
289
+ return this.switchTo(null).then(() => frame.reduce((p, frameLocator) => p.then(() => this.switchTo(frameLocator)), Promise.resolve()))
294
290
  }
295
291
  withinStore.frame = frame
296
292
  return this.switchTo(locator)
@@ -300,8 +296,8 @@ class Protractor extends Helper {
300
296
  const context = await global.element(guessLocator(locator) || global.by.css(locator))
301
297
  if (!context) throw new ElementNotFound(locator)
302
298
 
303
- this.browser.findElement = (l) => (l ? context.element(l).getWebElement() : context.getWebElement())
304
- this.browser.findElements = (l) => context.all(l).getWebElements()
299
+ this.browser.findElement = l => (l ? context.element(l).getWebElement() : context.getWebElement())
300
+ this.browser.findElements = l => context.all(l).getWebElements()
305
301
  return context
306
302
  }
307
303
 
@@ -320,7 +316,7 @@ class Protractor extends Helper {
320
316
  _session() {
321
317
  const defaultSession = this.browser
322
318
  return {
323
- start: async (opts) => {
319
+ start: async opts => {
324
320
  opts = this._validateConfig(Object.assign(this.options, opts))
325
321
  this.debugSection('New Browser', JSON.stringify(opts))
326
322
  const runner = new Runner(opts)
@@ -331,10 +327,10 @@ class Protractor extends Helper {
331
327
  await browser.manage().window().setSize(parseInt(res[0], 10), parseInt(res[1], 10))
332
328
  return browser.ready
333
329
  },
334
- stop: async (browser) => {
330
+ stop: async browser => {
335
331
  return browser.close()
336
332
  },
337
- loadVars: async (browser) => {
333
+ loadVars: async browser => {
338
334
  if (isWithin()) throw new Error("Can't start session inside within block")
339
335
  this.browser = browser
340
336
  loadGlobals(this.browser)
@@ -573,7 +569,7 @@ class Protractor extends Helper {
573
569
  if (!els.length) {
574
570
  els = await field.findElements(global.by.xpath(Locator.select.byValue(opt)))
575
571
  }
576
- els.forEach((el) => promises.push(el.click()))
572
+ els.forEach(el => promises.push(el.click()))
577
573
  }
578
574
 
579
575
  return Promise.all(promises)
@@ -595,7 +591,6 @@ class Protractor extends Helper {
595
591
  async pressKey(key) {
596
592
  let modifier
597
593
  if (Array.isArray(key) && ~['Control', 'Command', 'Shift', 'Alt'].indexOf(key[0])) {
598
- // eslint-disable-line no-bitwise
599
594
  modifier = Key[key[0].toUpperCase()]
600
595
  key = key[1]
601
596
  }
@@ -741,7 +736,7 @@ class Protractor extends Helper {
741
736
  const els = await this._locate(locator)
742
737
 
743
738
  const html = await Promise.all(
744
- els.map((el) => {
739
+ els.map(el => {
745
740
  return this.browser.executeScript('return arguments[0].innerHTML;', el)
746
741
  }),
747
742
  )
@@ -767,7 +762,7 @@ class Protractor extends Helper {
767
762
  */
768
763
  async grabValueFromAll(locator) {
769
764
  const els = await findFields(this.browser, locator)
770
- const values = await Promise.all(els.map((el) => el.getAttribute('value')))
765
+ const values = await Promise.all(els.map(el => el.getAttribute('value')))
771
766
 
772
767
  return values
773
768
  }
@@ -790,7 +785,7 @@ class Protractor extends Helper {
790
785
  */
791
786
  async grabCssPropertyFromAll(locator, cssProperty) {
792
787
  const els = await this._locate(locator, true)
793
- const values = await Promise.all(els.map((el) => el.getCssValue(cssProperty)))
788
+ const values = await Promise.all(els.map(el => el.getCssValue(cssProperty)))
794
789
 
795
790
  return values
796
791
  }
@@ -840,7 +835,7 @@ class Protractor extends Helper {
840
835
  * {{> seeInTitle }}
841
836
  */
842
837
  async seeInTitle(text) {
843
- return this.browser.getTitle().then((title) => stringIncludes('web page title').assert(text, title))
838
+ return this.browser.getTitle().then(title => stringIncludes('web page title').assert(text, title))
844
839
  }
845
840
 
846
841
  /**
@@ -855,14 +850,14 @@ class Protractor extends Helper {
855
850
  * {{> dontSeeInTitle }}
856
851
  */
857
852
  async dontSeeInTitle(text) {
858
- return this.browser.getTitle().then((title) => stringIncludes('web page title').negate(text, title))
853
+ return this.browser.getTitle().then(title => stringIncludes('web page title').negate(text, title))
859
854
  }
860
855
 
861
856
  /**
862
857
  * {{> grabTitle }}
863
858
  */
864
859
  async grabTitle() {
865
- return this.browser.getTitle().then((title) => {
860
+ return this.browser.getTitle().then(title => {
866
861
  this.debugSection('Title', title)
867
862
  return title
868
863
  })
@@ -873,8 +868,8 @@ class Protractor extends Helper {
873
868
  */
874
869
  async seeElement(locator) {
875
870
  let els = await this._locate(locator, true)
876
- els = await Promise.all(els.map((el) => el.isDisplayed()))
877
- return empty('elements').negate(els.filter((v) => v).fill('ELEMENT'))
871
+ els = await Promise.all(els.map(el => el.isDisplayed()))
872
+ return empty('elements').negate(els.filter(v => v).fill('ELEMENT'))
878
873
  }
879
874
 
880
875
  /**
@@ -882,33 +877,29 @@ class Protractor extends Helper {
882
877
  */
883
878
  async dontSeeElement(locator) {
884
879
  let els = await this._locate(locator, false)
885
- els = await Promise.all(els.map((el) => el.isDisplayed()))
886
- return empty('elements').assert(els.filter((v) => v).fill('ELEMENT'))
880
+ els = await Promise.all(els.map(el => el.isDisplayed()))
881
+ return empty('elements').assert(els.filter(v => v).fill('ELEMENT'))
887
882
  }
888
883
 
889
884
  /**
890
885
  * {{> seeElementInDOM }}
891
886
  */
892
887
  async seeElementInDOM(locator) {
893
- return this.browser
894
- .findElements(guessLocator(locator) || global.by.css(locator))
895
- .then((els) => empty('elements').negate(els.fill('ELEMENT')))
888
+ return this.browser.findElements(guessLocator(locator) || global.by.css(locator)).then(els => empty('elements').negate(els.fill('ELEMENT')))
896
889
  }
897
890
 
898
891
  /**
899
892
  * {{> dontSeeElementInDOM }}
900
893
  */
901
894
  async dontSeeElementInDOM(locator) {
902
- return this.browser
903
- .findElements(guessLocator(locator) || global.by.css(locator))
904
- .then((els) => empty('elements').assert(els.fill('ELEMENT')))
895
+ return this.browser.findElements(guessLocator(locator) || global.by.css(locator)).then(els => empty('elements').assert(els.fill('ELEMENT')))
905
896
  }
906
897
 
907
898
  /**
908
899
  * {{> seeInSource }}
909
900
  */
910
901
  async seeInSource(text) {
911
- return this.browser.getPageSource().then((source) => stringIncludes('HTML source of a page').assert(text, source))
902
+ return this.browser.getPageSource().then(source => stringIncludes('HTML source of a page').assert(text, source))
912
903
  }
913
904
 
914
905
  /**
@@ -922,7 +913,7 @@ class Protractor extends Helper {
922
913
  * {{> dontSeeInSource }}
923
914
  */
924
915
  async dontSeeInSource(text) {
925
- return this.browser.getPageSource().then((source) => stringIncludes('HTML source of a page').negate(text, source))
916
+ return this.browser.getPageSource().then(source => stringIncludes('HTML source of a page').negate(text, source))
926
917
  }
927
918
 
928
919
  /**
@@ -930,9 +921,7 @@ class Protractor extends Helper {
930
921
  */
931
922
  async seeNumberOfElements(locator, num) {
932
923
  const elements = await this._locate(locator)
933
- return equals(
934
- `expected number of elements (${new Locator(locator)}) is ${num}, but found ${elements.length}`,
935
- ).assert(elements.length, num)
924
+ return equals(`expected number of elements (${new Locator(locator)}) is ${num}, but found ${elements.length}`).assert(elements.length, num)
936
925
  }
937
926
 
938
927
  /**
@@ -940,10 +929,7 @@ class Protractor extends Helper {
940
929
  */
941
930
  async seeNumberOfVisibleElements(locator, num) {
942
931
  const res = await this.grabNumberOfVisibleElements(locator)
943
- return equals(`expected number of visible elements (${new Locator(locator)}) is ${num}, but found ${res}`).assert(
944
- res,
945
- num,
946
- )
932
+ return equals(`expected number of visible elements (${new Locator(locator)}) is ${num}, but found ${res}`).assert(res, num)
947
933
  }
948
934
 
949
935
  /**
@@ -951,7 +937,7 @@ class Protractor extends Helper {
951
937
  */
952
938
  async grabNumberOfVisibleElements(locator) {
953
939
  let els = await this._locate(locator)
954
- els = await Promise.all(els.map((el) => el.isDisplayed()))
940
+ els = await Promise.all(els.map(el => el.isDisplayed()))
955
941
  return els.length
956
942
  }
957
943
 
@@ -965,11 +951,11 @@ class Protractor extends Helper {
965
951
  const cssPropertiesCamelCase = convertCssPropertiesToCamelCase(cssProperties)
966
952
 
967
953
  const attributeNames = Object.keys(cssPropertiesCamelCase)
968
- const expectedValues = attributeNames.map((name) => cssPropertiesCamelCase[name])
954
+ const expectedValues = attributeNames.map(name => cssPropertiesCamelCase[name])
969
955
  const missingAttributes = []
970
956
 
971
957
  for (const el of els) {
972
- const attributeValues = await Promise.all(attributeNames.map((attr) => el.getCssValue(attr)))
958
+ const attributeValues = await Promise.all(attributeNames.map(attr => el.getCssValue(attr)))
973
959
 
974
960
  const missing = attributeValues.filter((actual, i) => {
975
961
  const prop = attributeNames[i]
@@ -983,9 +969,7 @@ class Protractor extends Helper {
983
969
  missingAttributes.push(...missing)
984
970
  }
985
971
  }
986
- return equals(
987
- `all elements (${new Locator(locator)}) to have CSS property ${JSON.stringify(cssProperties)}`,
988
- ).assert(missingAttributes.length, 0)
972
+ return equals(`all elements (${new Locator(locator)}) to have CSS property ${JSON.stringify(cssProperties)}`).assert(missingAttributes.length, 0)
989
973
  }
990
974
 
991
975
  /**
@@ -996,11 +980,11 @@ class Protractor extends Helper {
996
980
  assertElementExists(els, locator)
997
981
 
998
982
  const attributeNames = Object.keys(attributes)
999
- const expectedValues = attributeNames.map((name) => attributes[name])
983
+ const expectedValues = attributeNames.map(name => attributes[name])
1000
984
  const missingAttributes = []
1001
985
 
1002
986
  for (const el of els) {
1003
- const attributeValues = await Promise.all(attributeNames.map((attr) => el.getAttribute(attr)))
987
+ const attributeValues = await Promise.all(attributeNames.map(attr => el.getAttribute(attr)))
1004
988
  const missing = attributeValues.filter((actual, i) => {
1005
989
  if (expectedValues[i] instanceof RegExp) {
1006
990
  return expectedValues[i].test(actual)
@@ -1012,10 +996,7 @@ class Protractor extends Helper {
1012
996
  }
1013
997
  }
1014
998
 
1015
- return equals(`all elements (${new Locator(locator)}) to have attributes ${JSON.stringify(attributes)}`).assert(
1016
- missingAttributes.length,
1017
- 0,
1018
- )
999
+ return equals(`all elements (${new Locator(locator)}) to have attributes ${JSON.stringify(attributes)}`).assert(missingAttributes.length, 0)
1019
1000
  }
1020
1001
 
1021
1002
  /**
@@ -1037,28 +1018,28 @@ class Protractor extends Helper {
1037
1018
  * {{> seeInCurrentUrl }}
1038
1019
  */
1039
1020
  async seeInCurrentUrl(url) {
1040
- return this.browser.getCurrentUrl().then((currentUrl) => stringIncludes('url').assert(url, currentUrl))
1021
+ return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').assert(url, currentUrl))
1041
1022
  }
1042
1023
 
1043
1024
  /**
1044
1025
  * {{> dontSeeInCurrentUrl }}
1045
1026
  */
1046
1027
  async dontSeeInCurrentUrl(url) {
1047
- return this.browser.getCurrentUrl().then((currentUrl) => stringIncludes('url').negate(url, currentUrl))
1028
+ return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').negate(url, currentUrl))
1048
1029
  }
1049
1030
 
1050
1031
  /**
1051
1032
  * {{> seeCurrentUrlEquals }}
1052
1033
  */
1053
1034
  async seeCurrentUrlEquals(url) {
1054
- return this.browser.getCurrentUrl().then((currentUrl) => urlEquals(this.options.url).assert(url, currentUrl))
1035
+ return this.browser.getCurrentUrl().then(currentUrl => urlEquals(this.options.url).assert(url, currentUrl))
1055
1036
  }
1056
1037
 
1057
1038
  /**
1058
1039
  * {{> dontSeeCurrentUrlEquals }}
1059
1040
  */
1060
1041
  async dontSeeCurrentUrlEquals(url) {
1061
- return this.browser.getCurrentUrl().then((currentUrl) => urlEquals(this.options.url).negate(url, currentUrl))
1042
+ return this.browser.getCurrentUrl().then(currentUrl => urlEquals(this.options.url).negate(url, currentUrl))
1062
1043
  }
1063
1044
 
1064
1045
  /**
@@ -1073,7 +1054,7 @@ class Protractor extends Helper {
1073
1054
  const stream = fs.createWriteStream(outputFile)
1074
1055
  stream.write(Buffer.from(png, 'base64'))
1075
1056
  stream.end()
1076
- return new Promise((resolve) => stream.on('finish', resolve)) // eslint-disable-line no-promise-executor-return
1057
+ return new Promise(resolve => stream.on('finish', resolve))
1077
1058
  }
1078
1059
 
1079
1060
  const res = await this._locate(locator)
@@ -1096,7 +1077,7 @@ class Protractor extends Helper {
1096
1077
  const stream = fs.createWriteStream(outputFile)
1097
1078
  stream.write(Buffer.from(png, 'base64'))
1098
1079
  stream.end()
1099
- return new Promise((resolve) => stream.on('finish', resolve)) // eslint-disable-line no-promise-executor-return
1080
+ return new Promise(resolve => stream.on('finish', resolve))
1100
1081
  }
1101
1082
 
1102
1083
  if (!fullPage) {
@@ -1106,7 +1087,6 @@ class Protractor extends Helper {
1106
1087
  }
1107
1088
 
1108
1089
  let { width, height } = await this.browser.executeScript(() => ({
1109
- // eslint-disable-line
1110
1090
  height: document.body.scrollHeight,
1111
1091
  width: document.body.scrollWidth,
1112
1092
  }))
@@ -1136,7 +1116,7 @@ class Protractor extends Helper {
1136
1116
  return this.browser
1137
1117
  .manage()
1138
1118
  .getCookie(name)
1139
- .then((res) => truth(`cookie ${name}`, 'to be set').assert(res))
1119
+ .then(res => truth(`cookie ${name}`, 'to be set').assert(res))
1140
1120
  }
1141
1121
 
1142
1122
  /**
@@ -1146,7 +1126,7 @@ class Protractor extends Helper {
1146
1126
  return this.browser
1147
1127
  .manage()
1148
1128
  .getCookie(name)
1149
- .then((res) => truth(`cookie ${name}`, 'to be set').negate(res))
1129
+ .then(res => truth(`cookie ${name}`, 'to be set').negate(res))
1150
1130
  }
1151
1131
 
1152
1132
  /**
@@ -1244,11 +1224,11 @@ class Protractor extends Helper {
1244
1224
 
1245
1225
  const handles = await client.getAllWindowHandles()
1246
1226
  const currentHandle = await client.getWindowHandle()
1247
- const otherHandles = handles.filter((handle) => handle !== currentHandle)
1227
+ const otherHandles = handles.filter(handle => handle !== currentHandle)
1248
1228
 
1249
1229
  if (!otherHandles || !otherHandles.length) return
1250
1230
  let p = Promise.resolve()
1251
- otherHandles.forEach((handle) => {
1231
+ otherHandles.forEach(handle => {
1252
1232
  p = p.then(() =>
1253
1233
  client
1254
1234
  .switchTo()
@@ -1395,7 +1375,7 @@ class Protractor extends Helper {
1395
1375
  async waitForDetached(locator, sec = null) {
1396
1376
  const aSec = sec || this.options.waitForTimeoutInSeconds
1397
1377
  const el = global.element(guessLocator(locator) || global.by.css(locator))
1398
- return this.browser.wait(EC.not(EC.presenceOf(el)), aSec * 1000).catch((err) => {
1378
+ return this.browser.wait(EC.not(EC.presenceOf(el)), aSec * 1000).catch(err => {
1399
1379
  if (err.message && err.message.indexOf('Wait timed out after') > -1) {
1400
1380
  throw new Error(`element (${JSON.stringify(locator)}) still on page after ${sec} sec`)
1401
1381
  } else throw err
@@ -1455,9 +1435,9 @@ class Protractor extends Helper {
1455
1435
  return function () {
1456
1436
  return global.element
1457
1437
  .all(loc)
1458
- .filter((el) => el.isDisplayed())
1438
+ .filter(el => el.isDisplayed())
1459
1439
  .count()
1460
- .then((count) => count === expectedCount)
1440
+ .then(count => count === expectedCount)
1461
1441
  }
1462
1442
  }
1463
1443
 
@@ -1487,22 +1467,20 @@ class Protractor extends Helper {
1487
1467
  async waitForValue(field, value, sec = null) {
1488
1468
  const aSec = sec || this.options.waitForTimeoutInSeconds
1489
1469
 
1490
- const valueToBeInElementValue = (loc) => {
1470
+ const valueToBeInElementValue = loc => {
1491
1471
  return async () => {
1492
1472
  const els = await findFields(this.browser, loc)
1493
1473
 
1494
1474
  if (!els) {
1495
1475
  return false
1496
1476
  }
1497
- const values = await Promise.all(els.map((el) => el.getAttribute('value')))
1498
- return values.filter((part) => part.indexOf(value) >= 0).length > 0
1477
+ const values = await Promise.all(els.map(el => el.getAttribute('value')))
1478
+ return values.filter(part => part.indexOf(value) >= 0).length > 0
1499
1479
  }
1500
1480
  }
1501
1481
 
1502
1482
  return this.browser.wait(valueToBeInElementValue(field, value), aSec * 1000).catch(() => {
1503
- throw Error(
1504
- `element (${field}) is not in DOM or there is no element(${field}) with value "${value}" after ${aSec} sec`,
1505
- )
1483
+ throw Error(`element (${field}) is not in DOM or there is no element(${field}) with value "${value}" after ${aSec} sec`)
1506
1484
  })
1507
1485
  }
1508
1486
 
@@ -1530,7 +1508,7 @@ class Protractor extends Helper {
1530
1508
  const aSec = sec || this.options.waitForTimeoutInSeconds
1531
1509
  const waitTimeout = aSec * 1000
1532
1510
 
1533
- return this.browser.wait(EC.urlContains(urlPart), waitTimeout).catch(async (e) => {
1511
+ return this.browser.wait(EC.urlContains(urlPart), waitTimeout).catch(async e => {
1534
1512
  const currUrl = await this.browser.getCurrentUrl()
1535
1513
  if (/wait timed out after/i.test(e.message)) {
1536
1514
  throw new Error(`expected url to include ${urlPart}, but found ${currUrl}`)
@@ -1551,7 +1529,7 @@ class Protractor extends Helper {
1551
1529
  urlPart = baseUrl + urlPart
1552
1530
  }
1553
1531
 
1554
- return this.browser.wait(EC.urlIs(urlPart), waitTimeout).catch(async (e) => {
1532
+ return this.browser.wait(EC.urlIs(urlPart), waitTimeout).catch(async e => {
1555
1533
  const currUrl = await this.browser.getCurrentUrl()
1556
1534
  if (/wait timed out after/i.test(e.message)) {
1557
1535
  throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`)
@@ -1614,7 +1592,7 @@ class Protractor extends Helper {
1614
1592
  }
1615
1593
  const elem = res[0]
1616
1594
  const location = await elem.getLocation()
1617
- /* eslint-disable prefer-arrow-callback */
1595
+
1618
1596
  return this.executeScript(
1619
1597
  function (x, y) {
1620
1598
  return window.scrollTo(x, y)
@@ -1622,10 +1600,8 @@ class Protractor extends Helper {
1622
1600
  location.x + offsetX,
1623
1601
  location.y + offsetY,
1624
1602
  )
1625
- /* eslint-enable */
1626
1603
  }
1627
1604
 
1628
- /* eslint-disable prefer-arrow-callback, comma-dangle */
1629
1605
  return this.executeScript(
1630
1606
  function (x, y) {
1631
1607
  return window.scrollTo(x, y)
@@ -1633,7 +1609,6 @@ class Protractor extends Helper {
1633
1609
  offsetX,
1634
1610
  offsetY,
1635
1611
  )
1636
- /* eslint-enable */
1637
1612
  }
1638
1613
 
1639
1614
  /**
@@ -1647,30 +1622,24 @@ class Protractor extends Helper {
1647
1622
  * {{> scrollPageToBottom }}
1648
1623
  */
1649
1624
  async scrollPageToBottom() {
1650
- /* eslint-disable prefer-arrow-callback, comma-dangle */
1651
1625
  return this.executeScript(function () {
1652
1626
  const body = document.body
1653
1627
  const html = document.documentElement
1654
- window.scrollTo(
1655
- 0,
1656
- Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight),
1657
- )
1628
+ window.scrollTo(0, Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight))
1658
1629
  })
1659
- /* eslint-enable */
1660
1630
  }
1661
1631
 
1662
1632
  /**
1663
1633
  * {{> grabPageScrollPosition }}
1664
1634
  */
1665
1635
  async grabPageScrollPosition() {
1666
- /* eslint-disable comma-dangle */
1667
1636
  function getScrollPosition() {
1668
1637
  return {
1669
1638
  x: window.pageXOffset,
1670
1639
  y: window.pageYOffset,
1671
1640
  }
1672
1641
  }
1673
- /* eslint-enable comma-dangle */
1642
+
1674
1643
  return this.executeScript(getScrollPosition)
1675
1644
  }
1676
1645
 
@@ -1786,7 +1755,7 @@ async function proceedSee(assertType, text, context) {
1786
1755
  const els = await this._smartWait(() => this.browser.findElements(locator), enableSmartWait)
1787
1756
  const promises = []
1788
1757
  let source = ''
1789
- els.forEach((el) => promises.push(el.getText().then((elText) => (source += `| ${elText}`))))
1758
+ els.forEach(el => promises.push(el.getText().then(elText => (source += `| ${elText}`))))
1790
1759
  await Promise.all(promises)
1791
1760
  return stringIncludes(description)[assertType](text, source)
1792
1761
  }
@@ -1811,7 +1780,7 @@ async function proceedIsChecked(assertType, option) {
1811
1780
  const els = await findCheckable(this.browser, option)
1812
1781
  assertElementExists(els, option, 'Option')
1813
1782
  const elsSelected = []
1814
- els.forEach((el) => elsSelected.push(el.isSelected()))
1783
+ els.forEach(el => elsSelected.push(el.isSelected()))
1815
1784
  const values = await Promise.all(elsSelected)
1816
1785
  const selected = values.reduce((prev, cur) => prev || cur)
1817
1786
  return truth(`checkable ${option}`, 'to be checked')[assertType](selected)