codeceptjs 4.1.0-beta.1-esm-mocha → 4.2.0-beta.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 (49) hide show
  1. package/docs/alternative-browsers.md +153 -0
  2. package/docs/basics.md +9 -1
  3. package/docs/configuration.md +2 -0
  4. package/docs/helpers/CDPBrowser.md +2138 -0
  5. package/docs/helpers/Kitesurf.md +118 -0
  6. package/docs/helpers/Obscura.md +210 -0
  7. package/docs/migration-4.md +3 -1
  8. package/docs/parallel.md +10 -0
  9. package/docs/playwright.md +19 -0
  10. package/docs/plugins/screencast.md +18 -13
  11. package/docs/plugins.md +1 -1
  12. package/lib/command/info.js +11 -3
  13. package/lib/command/workers/runTests.js +14 -20
  14. package/lib/container.js +6 -0
  15. package/lib/data/context.js +10 -1
  16. package/lib/element/WebElement.js +5 -0
  17. package/lib/globals.js +2 -4
  18. package/lib/helper/Appium.js +22 -6
  19. package/lib/helper/CDPBrowser.js +3004 -0
  20. package/lib/helper/GraphQL.js +0 -8
  21. package/lib/helper/GraphQLDataFactory.js +0 -9
  22. package/lib/helper/Kitesurf.js +139 -0
  23. package/lib/helper/Obscura.js +344 -0
  24. package/lib/helper/Playwright.js +30 -3
  25. package/lib/helper/Puppeteer.js +43 -16
  26. package/lib/helper/WebDriver.js +43 -8
  27. package/lib/helper/clientscripts/cdpBrowserClient.js +486 -0
  28. package/lib/helper/clientscripts/xpathPolyfill.js +31 -0
  29. package/lib/helper/extras/CDPConnection.js +92 -0
  30. package/lib/helper/extras/CDPElementHandle.js +27 -0
  31. package/lib/helper/extras/apngAssembler.js +156 -0
  32. package/lib/html.js +9 -2
  33. package/lib/listener/retryEnhancer.js +2 -1
  34. package/lib/listener/steps.js +8 -0
  35. package/lib/mocha/hooks.js +10 -0
  36. package/lib/mocha/loadTests.js +9 -2
  37. package/lib/parser.js +14 -2
  38. package/lib/plugin/junitReporter.js +44 -7
  39. package/lib/plugin/screencast.js +116 -24
  40. package/lib/rerun.js +1 -1
  41. package/lib/step/base.js +15 -3
  42. package/lib/utils/loaderCheck.js +6 -0
  43. package/lib/utils/typescript.js +3 -1
  44. package/lib/utils.js +1 -1
  45. package/lib/workers.js +17 -0
  46. package/package.json +9 -6
  47. package/typings/index.d.ts +1 -0
  48. package/typings/promiseBasedTypes.d.ts +1833 -0
  49. package/typings/types.d.ts +1840 -0
package/lib/globals.js CHANGED
@@ -30,10 +30,8 @@ export async function initCodeceptGlobals(dir, config, container) {
30
30
  // pause/inject/share stay global even under noGlobals — they're the everyday
31
31
  // debugging/wiring entry points and have no useful import alternative for
32
32
  // page-object code that runs before the container is available.
33
- global.pause = async (...args) => {
34
- const pauseModule = await import('./pause.js')
35
- return (pauseModule.default || pauseModule)(...args)
36
- }
33
+ const pauseModule = await import('./pause.js')
34
+ global.pause = pauseModule.default || pauseModule
37
35
  global.inject = () => container.support()
38
36
  global.share = container.share
39
37
 
@@ -832,12 +832,12 @@ class Appium extends Webdriver {
832
832
  */
833
833
  async grabNetworkConnection() {
834
834
  onlyForApps.call(this, supportedPlatform.android)
835
- const res = await this.browser.getNetworkConnection()
835
+ const res = await this.browser.execute('mobile: getConnectivity')
836
836
  return {
837
- value: res,
838
- inAirplaneMode: res.inAirplaneMode,
839
- hasWifi: res.hasWifi,
840
- hasData: res.hasData,
837
+ value: (res.airplaneMode ? 1 : 0) | (res.wifi ? 2 : 0) | (res.data ? 4 : 0),
838
+ inAirplaneMode: res.airplaneMode,
839
+ hasWifi: res.wifi,
840
+ hasData: res.data,
841
841
  }
842
842
  }
843
843
 
@@ -978,7 +978,23 @@ class Appium extends Webdriver {
978
978
  */
979
979
  async setNetworkConnection(value) {
980
980
  onlyForApps.call(this, supportedPlatform.android)
981
- return this.browser.setNetworkConnection(value)
981
+ const connectivity = {
982
+ airplaneMode: !!(value & 1),
983
+ wifi: !!(value & 2),
984
+ data: !!(value & 4),
985
+ }
986
+ // `mobile: setConnectivity` runs `adb shell svc data <state>` for every field it receives,
987
+ // which fails with "Can't find service: phone" on images without telephony (e.g. tablets).
988
+ // Only a positive result is cached: a freshly booted device may not have registered a carrier
989
+ // yet, and caching that would strip `data` for the whole session.
990
+ if (!this._hasTelephony) {
991
+ const deviceInfo = await this.browser.execute('mobile: deviceInfo')
992
+ this._hasTelephony = !!deviceInfo?.carrierName
993
+ }
994
+ // Keep `data` on telephony-capable devices, otherwise the device stays online over cellular
995
+ // and going offline silently does nothing.
996
+ if (!this._hasTelephony) delete connectivity.data
997
+ return this.browser.execute('mobile: setConnectivity', connectivity)
982
998
  }
983
999
 
984
1000
  /**