codeceptjs 4.0.0-beta.4 → 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 (150) 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 +139 -87
  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/generate.js +10 -14
  17. package/lib/command/gherkin/snippets.js +75 -73
  18. package/lib/command/gherkin/steps.js +1 -1
  19. package/lib/command/info.js +42 -8
  20. package/lib/command/init.js +13 -12
  21. package/lib/command/interactive.js +10 -2
  22. package/lib/command/list.js +1 -1
  23. package/lib/command/run-multiple/chunk.js +48 -45
  24. package/lib/command/run-multiple.js +12 -35
  25. package/lib/command/run-workers.js +21 -58
  26. package/lib/command/utils.js +5 -6
  27. package/lib/command/workers/runTests.js +262 -220
  28. package/lib/container.js +386 -238
  29. package/lib/data/context.js +10 -13
  30. package/lib/data/dataScenarioConfig.js +8 -8
  31. package/lib/data/dataTableArgument.js +6 -6
  32. package/lib/data/table.js +5 -11
  33. package/lib/effects.js +223 -0
  34. package/lib/element/WebElement.js +327 -0
  35. package/lib/els.js +158 -0
  36. package/lib/event.js +21 -17
  37. package/lib/heal.js +88 -80
  38. package/lib/helper/AI.js +2 -1
  39. package/lib/helper/ApiDataFactory.js +3 -6
  40. package/lib/helper/Appium.js +47 -51
  41. package/lib/helper/FileSystem.js +3 -3
  42. package/lib/helper/GraphQLDataFactory.js +3 -3
  43. package/lib/helper/JSONResponse.js +75 -37
  44. package/lib/helper/Mochawesome.js +31 -9
  45. package/lib/helper/Nightmare.js +35 -53
  46. package/lib/helper/Playwright.js +262 -267
  47. package/lib/helper/Protractor.js +54 -77
  48. package/lib/helper/Puppeteer.js +246 -260
  49. package/lib/helper/REST.js +5 -17
  50. package/lib/helper/TestCafe.js +21 -44
  51. package/lib/helper/WebDriver.js +151 -170
  52. package/lib/helper/extras/Popup.js +22 -22
  53. package/lib/helper/testcafe/testcafe-utils.js +26 -27
  54. package/lib/listener/emptyRun.js +55 -0
  55. package/lib/listener/exit.js +7 -10
  56. package/lib/listener/{retry.js → globalRetry.js} +5 -5
  57. package/lib/listener/globalTimeout.js +165 -0
  58. package/lib/listener/helpers.js +15 -15
  59. package/lib/listener/mocha.js +1 -1
  60. package/lib/listener/result.js +12 -0
  61. package/lib/listener/retryEnhancer.js +85 -0
  62. package/lib/listener/steps.js +32 -18
  63. package/lib/listener/store.js +20 -0
  64. package/lib/mocha/asyncWrapper.js +231 -0
  65. package/lib/{interfaces → mocha}/bdd.js +3 -3
  66. package/lib/mocha/cli.js +308 -0
  67. package/lib/mocha/factory.js +104 -0
  68. package/lib/{interfaces → mocha}/featureConfig.js +32 -12
  69. package/lib/{interfaces → mocha}/gherkin.js +26 -28
  70. package/lib/mocha/hooks.js +112 -0
  71. package/lib/mocha/index.js +12 -0
  72. package/lib/mocha/inject.js +29 -0
  73. package/lib/{interfaces → mocha}/scenarioConfig.js +31 -7
  74. package/lib/mocha/suite.js +82 -0
  75. package/lib/mocha/test.js +181 -0
  76. package/lib/mocha/types.d.ts +42 -0
  77. package/lib/mocha/ui.js +232 -0
  78. package/lib/output.js +82 -62
  79. package/lib/pause.js +160 -138
  80. package/lib/plugin/analyze.js +396 -0
  81. package/lib/plugin/auth.js +435 -0
  82. package/lib/plugin/autoDelay.js +8 -8
  83. package/lib/plugin/autoLogin.js +3 -338
  84. package/lib/plugin/commentStep.js +6 -1
  85. package/lib/plugin/coverage.js +10 -19
  86. package/lib/plugin/customLocator.js +3 -3
  87. package/lib/plugin/customReporter.js +52 -0
  88. package/lib/plugin/eachElement.js +1 -1
  89. package/lib/plugin/fakerTransform.js +1 -1
  90. package/lib/plugin/heal.js +36 -9
  91. package/lib/plugin/htmlReporter.js +1947 -0
  92. package/lib/plugin/pageInfo.js +140 -0
  93. package/lib/plugin/retryFailedStep.js +17 -18
  94. package/lib/plugin/retryTo.js +2 -113
  95. package/lib/plugin/screenshotOnFail.js +17 -58
  96. package/lib/plugin/selenoid.js +15 -35
  97. package/lib/plugin/standardActingHelpers.js +4 -1
  98. package/lib/plugin/stepByStepReport.js +56 -17
  99. package/lib/plugin/stepTimeout.js +5 -12
  100. package/lib/plugin/subtitles.js +4 -4
  101. package/lib/plugin/tryTo.js +3 -102
  102. package/lib/plugin/wdio.js +8 -10
  103. package/lib/recorder.js +155 -124
  104. package/lib/rerun.js +43 -42
  105. package/lib/result.js +161 -0
  106. package/lib/secret.js +1 -1
  107. package/lib/step/base.js +239 -0
  108. package/lib/step/comment.js +10 -0
  109. package/lib/step/config.js +50 -0
  110. package/lib/step/func.js +46 -0
  111. package/lib/step/helper.js +50 -0
  112. package/lib/step/meta.js +99 -0
  113. package/lib/step/record.js +74 -0
  114. package/lib/step/retry.js +11 -0
  115. package/lib/step/section.js +55 -0
  116. package/lib/step.js +21 -332
  117. package/lib/steps.js +50 -0
  118. package/lib/store.js +37 -5
  119. package/lib/template/heal.js +2 -11
  120. package/lib/test-server.js +323 -0
  121. package/lib/timeout.js +66 -0
  122. package/lib/utils.js +351 -218
  123. package/lib/within.js +75 -55
  124. package/lib/workerStorage.js +2 -1
  125. package/lib/workers.js +386 -276
  126. package/package.json +76 -70
  127. package/translations/de-DE.js +4 -3
  128. package/translations/fr-FR.js +4 -3
  129. package/translations/index.js +1 -0
  130. package/translations/it-IT.js +4 -3
  131. package/translations/ja-JP.js +4 -3
  132. package/translations/nl-NL.js +76 -0
  133. package/translations/pl-PL.js +4 -3
  134. package/translations/pt-BR.js +4 -3
  135. package/translations/ru-RU.js +4 -3
  136. package/translations/utils.js +9 -0
  137. package/translations/zh-CN.js +4 -3
  138. package/translations/zh-TW.js +4 -3
  139. package/typings/index.d.ts +188 -186
  140. package/typings/promiseBasedTypes.d.ts +18 -705
  141. package/typings/types.d.ts +301 -804
  142. package/lib/cli.js +0 -256
  143. package/lib/helper/ExpectHelper.js +0 -391
  144. package/lib/helper/SoftExpectHelper.js +0 -381
  145. package/lib/listener/artifacts.js +0 -19
  146. package/lib/listener/timeout.js +0 -109
  147. package/lib/mochaFactory.js +0 -113
  148. package/lib/plugin/debugErrors.js +0 -67
  149. package/lib/scenario.js +0 -224
  150. 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)
@@ -740,7 +736,7 @@ class Protractor extends Helper {
740
736
  const els = await this._locate(locator)
741
737
 
742
738
  const html = await Promise.all(
743
- els.map((el) => {
739
+ els.map(el => {
744
740
  return this.browser.executeScript('return arguments[0].innerHTML;', el)
745
741
  }),
746
742
  )
@@ -766,7 +762,7 @@ class Protractor extends Helper {
766
762
  */
767
763
  async grabValueFromAll(locator) {
768
764
  const els = await findFields(this.browser, locator)
769
- const values = await Promise.all(els.map((el) => el.getAttribute('value')))
765
+ const values = await Promise.all(els.map(el => el.getAttribute('value')))
770
766
 
771
767
  return values
772
768
  }
@@ -789,7 +785,7 @@ class Protractor extends Helper {
789
785
  */
790
786
  async grabCssPropertyFromAll(locator, cssProperty) {
791
787
  const els = await this._locate(locator, true)
792
- const values = await Promise.all(els.map((el) => el.getCssValue(cssProperty)))
788
+ const values = await Promise.all(els.map(el => el.getCssValue(cssProperty)))
793
789
 
794
790
  return values
795
791
  }
@@ -839,7 +835,7 @@ class Protractor extends Helper {
839
835
  * {{> seeInTitle }}
840
836
  */
841
837
  async seeInTitle(text) {
842
- 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))
843
839
  }
844
840
 
845
841
  /**
@@ -854,14 +850,14 @@ class Protractor extends Helper {
854
850
  * {{> dontSeeInTitle }}
855
851
  */
856
852
  async dontSeeInTitle(text) {
857
- 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))
858
854
  }
859
855
 
860
856
  /**
861
857
  * {{> grabTitle }}
862
858
  */
863
859
  async grabTitle() {
864
- return this.browser.getTitle().then((title) => {
860
+ return this.browser.getTitle().then(title => {
865
861
  this.debugSection('Title', title)
866
862
  return title
867
863
  })
@@ -872,8 +868,8 @@ class Protractor extends Helper {
872
868
  */
873
869
  async seeElement(locator) {
874
870
  let els = await this._locate(locator, true)
875
- els = await Promise.all(els.map((el) => el.isDisplayed()))
876
- 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'))
877
873
  }
878
874
 
879
875
  /**
@@ -881,33 +877,29 @@ class Protractor extends Helper {
881
877
  */
882
878
  async dontSeeElement(locator) {
883
879
  let els = await this._locate(locator, false)
884
- els = await Promise.all(els.map((el) => el.isDisplayed()))
885
- 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'))
886
882
  }
887
883
 
888
884
  /**
889
885
  * {{> seeElementInDOM }}
890
886
  */
891
887
  async seeElementInDOM(locator) {
892
- return this.browser
893
- .findElements(guessLocator(locator) || global.by.css(locator))
894
- .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')))
895
889
  }
896
890
 
897
891
  /**
898
892
  * {{> dontSeeElementInDOM }}
899
893
  */
900
894
  async dontSeeElementInDOM(locator) {
901
- return this.browser
902
- .findElements(guessLocator(locator) || global.by.css(locator))
903
- .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')))
904
896
  }
905
897
 
906
898
  /**
907
899
  * {{> seeInSource }}
908
900
  */
909
901
  async seeInSource(text) {
910
- 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))
911
903
  }
912
904
 
913
905
  /**
@@ -921,7 +913,7 @@ class Protractor extends Helper {
921
913
  * {{> dontSeeInSource }}
922
914
  */
923
915
  async dontSeeInSource(text) {
924
- 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))
925
917
  }
926
918
 
927
919
  /**
@@ -929,9 +921,7 @@ class Protractor extends Helper {
929
921
  */
930
922
  async seeNumberOfElements(locator, num) {
931
923
  const elements = await this._locate(locator)
932
- return equals(
933
- `expected number of elements (${new Locator(locator)}) is ${num}, but found ${elements.length}`,
934
- ).assert(elements.length, num)
924
+ return equals(`expected number of elements (${new Locator(locator)}) is ${num}, but found ${elements.length}`).assert(elements.length, num)
935
925
  }
936
926
 
937
927
  /**
@@ -939,10 +929,7 @@ class Protractor extends Helper {
939
929
  */
940
930
  async seeNumberOfVisibleElements(locator, num) {
941
931
  const res = await this.grabNumberOfVisibleElements(locator)
942
- return equals(`expected number of visible elements (${new Locator(locator)}) is ${num}, but found ${res}`).assert(
943
- res,
944
- num,
945
- )
932
+ return equals(`expected number of visible elements (${new Locator(locator)}) is ${num}, but found ${res}`).assert(res, num)
946
933
  }
947
934
 
948
935
  /**
@@ -950,7 +937,7 @@ class Protractor extends Helper {
950
937
  */
951
938
  async grabNumberOfVisibleElements(locator) {
952
939
  let els = await this._locate(locator)
953
- els = await Promise.all(els.map((el) => el.isDisplayed()))
940
+ els = await Promise.all(els.map(el => el.isDisplayed()))
954
941
  return els.length
955
942
  }
956
943
 
@@ -964,11 +951,11 @@ class Protractor extends Helper {
964
951
  const cssPropertiesCamelCase = convertCssPropertiesToCamelCase(cssProperties)
965
952
 
966
953
  const attributeNames = Object.keys(cssPropertiesCamelCase)
967
- const expectedValues = attributeNames.map((name) => cssPropertiesCamelCase[name])
954
+ const expectedValues = attributeNames.map(name => cssPropertiesCamelCase[name])
968
955
  const missingAttributes = []
969
956
 
970
957
  for (const el of els) {
971
- const attributeValues = await Promise.all(attributeNames.map((attr) => el.getCssValue(attr)))
958
+ const attributeValues = await Promise.all(attributeNames.map(attr => el.getCssValue(attr)))
972
959
 
973
960
  const missing = attributeValues.filter((actual, i) => {
974
961
  const prop = attributeNames[i]
@@ -982,9 +969,7 @@ class Protractor extends Helper {
982
969
  missingAttributes.push(...missing)
983
970
  }
984
971
  }
985
- return equals(
986
- `all elements (${new Locator(locator)}) to have CSS property ${JSON.stringify(cssProperties)}`,
987
- ).assert(missingAttributes.length, 0)
972
+ return equals(`all elements (${new Locator(locator)}) to have CSS property ${JSON.stringify(cssProperties)}`).assert(missingAttributes.length, 0)
988
973
  }
989
974
 
990
975
  /**
@@ -995,11 +980,11 @@ class Protractor extends Helper {
995
980
  assertElementExists(els, locator)
996
981
 
997
982
  const attributeNames = Object.keys(attributes)
998
- const expectedValues = attributeNames.map((name) => attributes[name])
983
+ const expectedValues = attributeNames.map(name => attributes[name])
999
984
  const missingAttributes = []
1000
985
 
1001
986
  for (const el of els) {
1002
- const attributeValues = await Promise.all(attributeNames.map((attr) => el.getAttribute(attr)))
987
+ const attributeValues = await Promise.all(attributeNames.map(attr => el.getAttribute(attr)))
1003
988
  const missing = attributeValues.filter((actual, i) => {
1004
989
  if (expectedValues[i] instanceof RegExp) {
1005
990
  return expectedValues[i].test(actual)
@@ -1011,10 +996,7 @@ class Protractor extends Helper {
1011
996
  }
1012
997
  }
1013
998
 
1014
- return equals(`all elements (${new Locator(locator)}) to have attributes ${JSON.stringify(attributes)}`).assert(
1015
- missingAttributes.length,
1016
- 0,
1017
- )
999
+ return equals(`all elements (${new Locator(locator)}) to have attributes ${JSON.stringify(attributes)}`).assert(missingAttributes.length, 0)
1018
1000
  }
1019
1001
 
1020
1002
  /**
@@ -1036,28 +1018,28 @@ class Protractor extends Helper {
1036
1018
  * {{> seeInCurrentUrl }}
1037
1019
  */
1038
1020
  async seeInCurrentUrl(url) {
1039
- return this.browser.getCurrentUrl().then((currentUrl) => stringIncludes('url').assert(url, currentUrl))
1021
+ return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').assert(url, currentUrl))
1040
1022
  }
1041
1023
 
1042
1024
  /**
1043
1025
  * {{> dontSeeInCurrentUrl }}
1044
1026
  */
1045
1027
  async dontSeeInCurrentUrl(url) {
1046
- return this.browser.getCurrentUrl().then((currentUrl) => stringIncludes('url').negate(url, currentUrl))
1028
+ return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').negate(url, currentUrl))
1047
1029
  }
1048
1030
 
1049
1031
  /**
1050
1032
  * {{> seeCurrentUrlEquals }}
1051
1033
  */
1052
1034
  async seeCurrentUrlEquals(url) {
1053
- 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))
1054
1036
  }
1055
1037
 
1056
1038
  /**
1057
1039
  * {{> dontSeeCurrentUrlEquals }}
1058
1040
  */
1059
1041
  async dontSeeCurrentUrlEquals(url) {
1060
- 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))
1061
1043
  }
1062
1044
 
1063
1045
  /**
@@ -1072,7 +1054,7 @@ class Protractor extends Helper {
1072
1054
  const stream = fs.createWriteStream(outputFile)
1073
1055
  stream.write(Buffer.from(png, 'base64'))
1074
1056
  stream.end()
1075
- return new Promise((resolve) => stream.on('finish', resolve)) // eslint-disable-line no-promise-executor-return
1057
+ return new Promise(resolve => stream.on('finish', resolve))
1076
1058
  }
1077
1059
 
1078
1060
  const res = await this._locate(locator)
@@ -1095,7 +1077,7 @@ class Protractor extends Helper {
1095
1077
  const stream = fs.createWriteStream(outputFile)
1096
1078
  stream.write(Buffer.from(png, 'base64'))
1097
1079
  stream.end()
1098
- return new Promise((resolve) => stream.on('finish', resolve)) // eslint-disable-line no-promise-executor-return
1080
+ return new Promise(resolve => stream.on('finish', resolve))
1099
1081
  }
1100
1082
 
1101
1083
  if (!fullPage) {
@@ -1134,7 +1116,7 @@ class Protractor extends Helper {
1134
1116
  return this.browser
1135
1117
  .manage()
1136
1118
  .getCookie(name)
1137
- .then((res) => truth(`cookie ${name}`, 'to be set').assert(res))
1119
+ .then(res => truth(`cookie ${name}`, 'to be set').assert(res))
1138
1120
  }
1139
1121
 
1140
1122
  /**
@@ -1144,7 +1126,7 @@ class Protractor extends Helper {
1144
1126
  return this.browser
1145
1127
  .manage()
1146
1128
  .getCookie(name)
1147
- .then((res) => truth(`cookie ${name}`, 'to be set').negate(res))
1129
+ .then(res => truth(`cookie ${name}`, 'to be set').negate(res))
1148
1130
  }
1149
1131
 
1150
1132
  /**
@@ -1242,11 +1224,11 @@ class Protractor extends Helper {
1242
1224
 
1243
1225
  const handles = await client.getAllWindowHandles()
1244
1226
  const currentHandle = await client.getWindowHandle()
1245
- const otherHandles = handles.filter((handle) => handle !== currentHandle)
1227
+ const otherHandles = handles.filter(handle => handle !== currentHandle)
1246
1228
 
1247
1229
  if (!otherHandles || !otherHandles.length) return
1248
1230
  let p = Promise.resolve()
1249
- otherHandles.forEach((handle) => {
1231
+ otherHandles.forEach(handle => {
1250
1232
  p = p.then(() =>
1251
1233
  client
1252
1234
  .switchTo()
@@ -1393,7 +1375,7 @@ class Protractor extends Helper {
1393
1375
  async waitForDetached(locator, sec = null) {
1394
1376
  const aSec = sec || this.options.waitForTimeoutInSeconds
1395
1377
  const el = global.element(guessLocator(locator) || global.by.css(locator))
1396
- 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 => {
1397
1379
  if (err.message && err.message.indexOf('Wait timed out after') > -1) {
1398
1380
  throw new Error(`element (${JSON.stringify(locator)}) still on page after ${sec} sec`)
1399
1381
  } else throw err
@@ -1453,9 +1435,9 @@ class Protractor extends Helper {
1453
1435
  return function () {
1454
1436
  return global.element
1455
1437
  .all(loc)
1456
- .filter((el) => el.isDisplayed())
1438
+ .filter(el => el.isDisplayed())
1457
1439
  .count()
1458
- .then((count) => count === expectedCount)
1440
+ .then(count => count === expectedCount)
1459
1441
  }
1460
1442
  }
1461
1443
 
@@ -1485,22 +1467,20 @@ class Protractor extends Helper {
1485
1467
  async waitForValue(field, value, sec = null) {
1486
1468
  const aSec = sec || this.options.waitForTimeoutInSeconds
1487
1469
 
1488
- const valueToBeInElementValue = (loc) => {
1470
+ const valueToBeInElementValue = loc => {
1489
1471
  return async () => {
1490
1472
  const els = await findFields(this.browser, loc)
1491
1473
 
1492
1474
  if (!els) {
1493
1475
  return false
1494
1476
  }
1495
- const values = await Promise.all(els.map((el) => el.getAttribute('value')))
1496
- 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
1497
1479
  }
1498
1480
  }
1499
1481
 
1500
1482
  return this.browser.wait(valueToBeInElementValue(field, value), aSec * 1000).catch(() => {
1501
- throw Error(
1502
- `element (${field}) is not in DOM or there is no element(${field}) with value "${value}" after ${aSec} sec`,
1503
- )
1483
+ throw Error(`element (${field}) is not in DOM or there is no element(${field}) with value "${value}" after ${aSec} sec`)
1504
1484
  })
1505
1485
  }
1506
1486
 
@@ -1528,7 +1508,7 @@ class Protractor extends Helper {
1528
1508
  const aSec = sec || this.options.waitForTimeoutInSeconds
1529
1509
  const waitTimeout = aSec * 1000
1530
1510
 
1531
- return this.browser.wait(EC.urlContains(urlPart), waitTimeout).catch(async (e) => {
1511
+ return this.browser.wait(EC.urlContains(urlPart), waitTimeout).catch(async e => {
1532
1512
  const currUrl = await this.browser.getCurrentUrl()
1533
1513
  if (/wait timed out after/i.test(e.message)) {
1534
1514
  throw new Error(`expected url to include ${urlPart}, but found ${currUrl}`)
@@ -1549,7 +1529,7 @@ class Protractor extends Helper {
1549
1529
  urlPart = baseUrl + urlPart
1550
1530
  }
1551
1531
 
1552
- return this.browser.wait(EC.urlIs(urlPart), waitTimeout).catch(async (e) => {
1532
+ return this.browser.wait(EC.urlIs(urlPart), waitTimeout).catch(async e => {
1553
1533
  const currUrl = await this.browser.getCurrentUrl()
1554
1534
  if (/wait timed out after/i.test(e.message)) {
1555
1535
  throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`)
@@ -1645,10 +1625,7 @@ class Protractor extends Helper {
1645
1625
  return this.executeScript(function () {
1646
1626
  const body = document.body
1647
1627
  const html = document.documentElement
1648
- window.scrollTo(
1649
- 0,
1650
- Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight),
1651
- )
1628
+ window.scrollTo(0, Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight))
1652
1629
  })
1653
1630
  }
1654
1631
 
@@ -1778,7 +1755,7 @@ async function proceedSee(assertType, text, context) {
1778
1755
  const els = await this._smartWait(() => this.browser.findElements(locator), enableSmartWait)
1779
1756
  const promises = []
1780
1757
  let source = ''
1781
- els.forEach((el) => promises.push(el.getText().then((elText) => (source += `| ${elText}`))))
1758
+ els.forEach(el => promises.push(el.getText().then(elText => (source += `| ${elText}`))))
1782
1759
  await Promise.all(promises)
1783
1760
  return stringIncludes(description)[assertType](text, source)
1784
1761
  }
@@ -1803,7 +1780,7 @@ async function proceedIsChecked(assertType, option) {
1803
1780
  const els = await findCheckable(this.browser, option)
1804
1781
  assertElementExists(els, option, 'Option')
1805
1782
  const elsSelected = []
1806
- els.forEach((el) => elsSelected.push(el.isSelected()))
1783
+ els.forEach(el => elsSelected.push(el.isSelected()))
1807
1784
  const values = await Promise.all(elsSelected)
1808
1785
  const selected = values.reduce((prev, cur) => prev || cur)
1809
1786
  return truth(`checkable ${option}`, 'to be checked')[assertType](selected)