diff --git a/package.json b/package.json index 5dfaa0c4b..5359a0d13 100644 --- a/package.json +++ b/package.json @@ -82,23 +82,19 @@ "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", "@types/bluebird": "^3.5.38", - "@types/chai": "^4.3.5", - "@types/chai-as-promised": "^7.1.5", "@types/lodash": "^4.14.194", "@types/mocha": "^10.0.1", "@types/node": "^20.2.3", "@types/portscanner": "^2.1.1", "@types/semver": "^7.5.0", - "@types/sinon": "^17.0.0", - "@types/sinon-chai": "^3.2.9", "@types/source-map-support": "^0.x", "@types/teen_process": "^2.0.0", "@types/ws": "^8.5.4", "@xmldom/xmldom": "^0.x", "android-apidemos": "^4.1.1", "appium": "^2.0.0-rc.3", - "chai": "^4.1.2", - "chai-as-promised": "^7.1.1", + "chai": "^5.1.1", + "chai-as-promised": "^8.0.0", "conventional-changelog-conventionalcommits": "^8.0.0", "fancy-log": "^2.0.0", "mocha": "^10.0.0", diff --git a/test/functional/commands/file-movement-e2e-specs.js b/test/functional/commands/file-movement-e2e-specs.js index 9e09094cb..81162f561 100644 --- a/test/functional/commands/file-movement-e2e-specs.js +++ b/test/functional/commands/file-movement-e2e-specs.js @@ -1,5 +1,3 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import _ from 'lodash'; import B from 'bluebird'; import stream from 'stream'; @@ -8,12 +6,17 @@ import { APIDEMOS_CAPS } from '../desired'; import { initSession, deleteSession } from '../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('file movement', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/find/by-accessibility-id-e2e-specs.js b/test/functional/commands/find/by-accessibility-id-e2e-specs.js index 0f7354f8f..6ee0042d0 100644 --- a/test/functional/commands/find/by-accessibility-id-e2e-specs.js +++ b/test/functional/commands/find/by-accessibility-id-e2e-specs.js @@ -1,15 +1,18 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - accessibility ID', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/find/by-css-e2e-specs.js b/test/functional/commands/find/by-css-e2e-specs.js index 208e197d6..bca274957 100644 --- a/test/functional/commands/find/by-css-e2e-specs.js +++ b/test/functional/commands/find/by-css-e2e-specs.js @@ -1,15 +1,17 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - CSS', function () { let driver; + let chai; before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/find/by-id-e2e-specs.js b/test/functional/commands/find/by-id-e2e-specs.js index 4d4f06f54..336a9cc32 100644 --- a/test/functional/commands/find/by-id-e2e-specs.js +++ b/test/functional/commands/find/by-id-e2e-specs.js @@ -1,15 +1,18 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - ID', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/find/by-image-e2e-specs.js b/test/functional/commands/find/by-image-e2e-specs.js index 3985d6a07..4b6ffef45 100644 --- a/test/functional/commands/find/by-image-e2e-specs.js +++ b/test/functional/commands/find/by-image-e2e-specs.js @@ -1,22 +1,24 @@ -import chai from 'chai'; import B from 'bluebird'; import path from 'path'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS, amendCapabilities } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - const START_IMG = path.resolve(__dirname, '..', '..', 'assets', 'start-button.png'); const STOP_IMG = path.resolve(__dirname, '..', '..', 'assets', 'stop-button.png'); const SQUARES_IMG = path.resolve(__dirname, '..', '..', 'assets', 'checkered-squares.png'); describe('Find - Image', function () { let driver; + let chai; before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + // TODO: @appium/images-plugin needs to be installed this.skip(); const caps = amendCapabilities(APIDEMOS_CAPS, { diff --git a/test/functional/commands/find/by-uiautomator-e2e-specs.js b/test/functional/commands/find/by-uiautomator-e2e-specs.js index 2ccfc0bf0..8b529b0df 100644 --- a/test/functional/commands/find/by-uiautomator-e2e-specs.js +++ b/test/functional/commands/find/by-uiautomator-e2e-specs.js @@ -1,15 +1,18 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - uiautomator', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); await driver.updateSettings({'enableNotificationListener': false}); await driver.setTimeout({ implicit: 20000 }); diff --git a/test/functional/commands/find/by-xpath-e2e-specs.js b/test/functional/commands/find/by-xpath-e2e-specs.js index edbe8fe2e..b68ed79b5 100644 --- a/test/functional/commands/find/by-xpath-e2e-specs.js +++ b/test/functional/commands/find/by-xpath-e2e-specs.js @@ -1,19 +1,22 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - const atv = 'android.widget.TextView'; const f = 'android.widget.FrameLayout'; describe('Find - xpath', function () { let driver; + let chai; + before(async function () { driver = await initSession(APIDEMOS_CAPS); + + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); }); after(async function () { await deleteSession(); diff --git a/test/functional/commands/find/find-basic-e2e-specs.js b/test/functional/commands/find/find-basic-e2e-specs.js index 9f9ada8dd..0c73b7139 100644 --- a/test/functional/commands/find/find-basic-e2e-specs.js +++ b/test/functional/commands/find/find-basic-e2e-specs.js @@ -1,16 +1,19 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - basic', function () { let driver; + let chai; let singleResourceId = 'decor_content_parent'; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/find/find-system-ui-el-e2e-specs.js b/test/functional/commands/find/find-system-ui-el-e2e-specs.js index bb832743d..8bda0757a 100644 --- a/test/functional/commands/find/find-system-ui-el-e2e-specs.js +++ b/test/functional/commands/find/find-system-ui-el-e2e-specs.js @@ -1,16 +1,18 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { initSession, deleteSession } from '../../helpers/session'; import { SETTINGS_CAPS } from '../../desired'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - android ui elements', function () { let driver; + let chai; before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(SETTINGS_CAPS); }); after(async function () { diff --git a/test/functional/commands/find/from-el-e2e-specs.js b/test/functional/commands/find/from-el-e2e-specs.js index daf1fb401..6bea475df 100644 --- a/test/functional/commands/find/from-el-e2e-specs.js +++ b/test/functional/commands/find/from-el-e2e-specs.js @@ -1,17 +1,20 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - from element', function () { const atv = 'android.widget.TextView'; const alv = 'android.widget.ListView'; let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/find/invalid-strategy-e2e-specs.js b/test/functional/commands/find/invalid-strategy-e2e-specs.js index 019105f8a..4ab362728 100644 --- a/test/functional/commands/find/invalid-strategy-e2e-specs.js +++ b/test/functional/commands/find/invalid-strategy-e2e-specs.js @@ -1,15 +1,18 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('Find - invalid strategy', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/general/attribute-e2e-specs.js b/test/functional/commands/general/attribute-e2e-specs.js index 8404dcc77..b6d20a2af 100644 --- a/test/functional/commands/general/attribute-e2e-specs.js +++ b/test/functional/commands/general/attribute-e2e-specs.js @@ -1,16 +1,19 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - -let driver; -let animationEl; describe('apidemo - attributes', function () { + let chai; + let driver; + let animationEl; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); animationEl = await driver.$('~Animation'); await animationEl.waitForDisplayed({ timeout: 5000 }); diff --git a/test/functional/commands/general/context-e2e-specs.js b/test/functional/commands/general/context-e2e-specs.js index 32ea465f8..351d6afe4 100644 --- a/test/functional/commands/general/context-e2e-specs.js +++ b/test/functional/commands/general/context-e2e-specs.js @@ -1,18 +1,22 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS, amendCapabilities } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; - -chai.should(); -chai.use(chaiAsPromised); - const WEBVIEW = 'WEBVIEW_io.appium.android.apis'; const NATIVE = 'NATIVE_APP'; const NATIVE_LOCATOR = "//*[@class='android.widget.TextView']"; const WEBVIEW_LOCATOR = "//*[text()='This page is a Selenium sandbox']"; + describe('apidemo - context', function () { + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); + describe('general', function () { let driver; before(async function () { diff --git a/test/functional/commands/general/element-e2e-specs.js b/test/functional/commands/general/element-e2e-specs.js index 6cba2811f..d45d3e474 100644 --- a/test/functional/commands/general/element-e2e-specs.js +++ b/test/functional/commands/general/element-e2e-specs.js @@ -1,5 +1,3 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import _ from 'lodash'; import { APIDEMOS_CAPS, amendCapabilities } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; @@ -7,15 +5,20 @@ import { retryInterval } from 'asyncbox'; import { util } from 'appium/support'; -chai.should(); -chai.use(chaiAsPromised); - const textFieldsActivity = '.view.TextFields'; describe('apidemo - element', function () { let driver; let el; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + const caps = amendCapabilities(APIDEMOS_CAPS, { 'appium:appActivity': textFieldsActivity, }); diff --git a/test/functional/commands/general/general-e2e-specs.js b/test/functional/commands/general/general-e2e-specs.js index 7c8f09cef..4eaa140d0 100644 --- a/test/functional/commands/general/general-e2e-specs.js +++ b/test/functional/commands/general/general-e2e-specs.js @@ -1,11 +1,7 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; import { waitForCondition } from 'asyncbox'; -chai.should(); -chai.use(chaiAsPromised); async function expectPackageAndActivity(driver, pkg, activity, timeoutMs = 5000) { await waitForCondition(async () => @@ -20,7 +16,15 @@ async function expectPackageAndActivity(driver, pkg, activity, timeoutMs = 5000) describe('general', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/general/ime-e2e-specs.js b/test/functional/commands/general/ime-e2e-specs.js index 22a9fcfec..b56faa707 100644 --- a/test/functional/commands/general/ime-e2e-specs.js +++ b/test/functional/commands/general/ime-e2e-specs.js @@ -1,19 +1,22 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - const unicodeImeId = 'io.appium.settings/.UnicodeIME'; describe('apidemo - IME', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); driver = await initSession(Object.assign(APIDEMOS_CAPS)); }); + beforeEach(async function () { await driver.startActivity('io.appium.android.apis', 'io.appium.android.apis.ApiDemos'); }); diff --git a/test/functional/commands/general/mobile-command-e2e-specs.js b/test/functional/commands/general/mobile-command-e2e-specs.js index 04ecff54e..1d5ef6e83 100644 --- a/test/functional/commands/general/mobile-command-e2e-specs.js +++ b/test/functional/commands/general/mobile-command-e2e-specs.js @@ -1,14 +1,18 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); describe('mobile', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/general/network-e2e-specs.js b/test/functional/commands/general/network-e2e-specs.js index 5ba35b489..4f6e904c9 100644 --- a/test/functional/commands/general/network-e2e-specs.js +++ b/test/functional/commands/general/network-e2e-specs.js @@ -1,15 +1,17 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS, amendCapabilities } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('wifi @skip-ci', function () { let driver; + let chai; before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + const caps = amendCapabilities(APIDEMOS_CAPS, { 'appium:appActivity': '.view.TextFields', }); diff --git a/test/functional/commands/general/source-e2e-specs.js b/test/functional/commands/general/source-e2e-specs.js index eb5debb5c..e41ecac55 100644 --- a/test/functional/commands/general/source-e2e-specs.js +++ b/test/functional/commands/general/source-e2e-specs.js @@ -1,16 +1,20 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import {DOMParser} from '@xmldom/xmldom'; import xpath from 'xpath'; import {APIDEMOS_CAPS} from '../../desired'; import {initSession, deleteSession} from '../../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); describe('apidemo - source', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + driver = await initSession(APIDEMOS_CAPS); }); after(async function () { diff --git a/test/functional/commands/general/url-e2e-specs.js b/test/functional/commands/general/url-e2e-specs.js index 20f5a3008..7244afd44 100644 --- a/test/functional/commands/general/url-e2e-specs.js +++ b/test/functional/commands/general/url-e2e-specs.js @@ -1,15 +1,19 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { BROWSER_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; import { ADB } from 'appium-adb'; -chai.should(); -chai.use(chaiAsPromised); describe('setUrl', function () { let driver; + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + const adb = new ADB(); const hasChrome = await adb.isAppInstalled('com.android.chrome'); if (!hasChrome) { diff --git a/test/functional/commands/geo-location-e2e-specs.js b/test/functional/commands/geo-location-e2e-specs.js index d926ecf69..3f6bb06a1 100644 --- a/test/functional/commands/geo-location-e2e-specs.js +++ b/test/functional/commands/geo-location-e2e-specs.js @@ -1,5 +1,3 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { retryInterval } from 'asyncbox'; import { GPS_DEMO_CAPS } from '../desired'; import { initSession, deleteSession } from '../helpers/session'; @@ -7,11 +5,18 @@ import B from 'bluebird'; import ADB from 'appium-adb'; -chai.should(); -chai.use(chaiAsPromised); - describe('geo-location -', function () { let driver; + let chai; + + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); + beforeEach(async function () { const adb = new ADB(); if (await adb.getApiLevel() >= 30) { diff --git a/test/functional/commands/keyboard/keyboard-e2e-specs.js b/test/functional/commands/keyboard/keyboard-e2e-specs.js index 4f056a222..e6d185b77 100644 --- a/test/functional/commands/keyboard/keyboard-e2e-specs.js +++ b/test/functional/commands/keyboard/keyboard-e2e-specs.js @@ -1,5 +1,3 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import _ from 'lodash'; import B from 'bluebird'; import { retryInterval } from 'asyncbox'; @@ -7,10 +5,6 @@ import { APIDEMOS_CAPS } from '../../desired'; import { initSession, deleteSession } from '../../helpers/session'; import ADB from 'appium-adb'; - -chai.should(); -chai.use(chaiAsPromised); - const BUTTON_CLASS = 'android.widget.Button'; const EDITTEXT_CLASS = 'android.widget.EditText'; @@ -143,6 +137,15 @@ const languageTests = [ ]; describe('keyboard', function () { + let chai; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); + describe('ascii', function () { let driver; before(async function () { diff --git a/test/functional/commands/orientation-e2e-specs.js b/test/functional/commands/orientation-e2e-specs.js index d38d45f4a..95bf3bda5 100644 --- a/test/functional/commands/orientation-e2e-specs.js +++ b/test/functional/commands/orientation-e2e-specs.js @@ -1,17 +1,21 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import B from 'bluebird'; import { APIDEMOS_CAPS, amendCapabilities } from '../desired'; import { initSession, deleteSession } from '../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('apidemo - orientation -', function () { let driver; + let chai; describe('initial -', function () { + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); + afterEach(async function () { await driver.setOrientation('PORTRAIT'); await deleteSession(); diff --git a/test/functional/commands/strings-e2e-specs.js b/test/functional/commands/strings-e2e-specs.js index a0c19e587..2be27a302 100644 --- a/test/functional/commands/strings-e2e-specs.js +++ b/test/functional/commands/strings-e2e-specs.js @@ -1,14 +1,18 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { APIDEMOS_CAPS, amendCapabilities } from '../desired'; import { initSession, deleteSession } from '../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - describe('strings', function () { let driver; + let chai; + + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); describe('specific language', function () { before(async function () { diff --git a/test/functional/commands/viewport-e2e-specs.js b/test/functional/commands/viewport-e2e-specs.js index a26dc936e..3ffb4dfbd 100644 --- a/test/functional/commands/viewport-e2e-specs.js +++ b/test/functional/commands/viewport-e2e-specs.js @@ -1,21 +1,24 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import sharp from 'sharp'; import {SCROLL_CAPS} from '../desired'; import {initSession, deleteSession, attemptToDismissAlert} from '../helpers/session'; -chai.should(); -chai.use(chaiAsPromised); - -const {expect} = chai; describe('testViewportCommands', function () { /** @type {import('../../../lib/driver').AndroidUiautomator2Driver} */ let driver; + let chai; + let expect; const caps = SCROLL_CAPS; before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + expect = chai.expect; + driver = await initSession(caps); }); diff --git a/test/functional/driver-e2e-specs.js b/test/functional/driver-e2e-specs.js index 6f9558938..cfe30b573 100644 --- a/test/functional/driver-e2e-specs.js +++ b/test/functional/driver-e2e-specs.js @@ -1,5 +1,3 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import ADB from 'appium-adb'; import { APIDEMOS_CAPS, amendCapabilities } from './desired'; import { initSession, deleteSession } from './helpers/session'; @@ -7,9 +5,6 @@ import B from 'bluebird'; import { retryInterval } from 'asyncbox'; -chai.should(); -chai.use(chaiAsPromised); - const APIDEMOS_PACKAGE = 'io.appium.android.apis'; const APIDEMOS_MAIN_ACTIVITY = '.ApiDemos'; const APIDEMOS_SPLIT_TOUCH_ACTIVITY = '.view.SplitTouchView'; @@ -29,6 +24,15 @@ async function killAndPrepareServer (oldPort, newPort) { describe('createSession', function () { let driver; + let chai; + + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); describe('default adb port', function () { afterEach(async function () { diff --git a/test/unit/commands/general-specs.js b/test/unit/commands/general-specs.js index b044a8dfa..3076403cf 100644 --- a/test/unit/commands/general-specs.js +++ b/test/unit/commands/general-specs.js @@ -1,19 +1,28 @@ // @ts-check -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import sinon from 'sinon'; import {AndroidUiautomator2Driver} from '../../../lib/driver'; import ADB from 'appium-adb'; import sinonChai from 'sinon-chai'; -const {expect} = chai; -chai.use(chaiAsPromised).use(sinonChai); describe('General', function () { let driver; /** @type {import('sinon').SinonSandbox} */ let sandbox; + let chai; + let expect; + + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + chai.use(sinonChai); + + expect = chai.expect; + }); beforeEach(function () { sandbox = sinon.createSandbox(); diff --git a/test/unit/css-converter-specs.js b/test/unit/css-converter-specs.js index bb40be715..c270ce82a 100644 --- a/test/unit/css-converter-specs.js +++ b/test/unit/css-converter-specs.js @@ -1,11 +1,16 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import CssConverter from '../../lib/css-converter'; -chai.should(); -chai.use(chaiAsPromised); - describe('css-converter.js', function () { + let chai; + + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); + describe('simple cases', function () { const simpleCases = [ ['android.widget.TextView', 'new UiSelector().className("android.widget.TextView")'], diff --git a/test/unit/driver-specs.js b/test/unit/driver-specs.js index 0bd6dc2cd..4e3e4dcb2 100644 --- a/test/unit/driver-specs.js +++ b/test/unit/driver-specs.js @@ -1,13 +1,9 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import {AndroidUiautomator2Driver} from '../../lib/driver'; import sinon from 'sinon'; import path from 'path'; import B from 'bluebird'; import {ADB} from 'appium-adb'; -chai.should(); -chai.use(chaiAsPromised); const sandbox = sinon.createSandbox(); function defaultStub(driver) { @@ -22,6 +18,16 @@ function defaultStub(driver) { } describe('driver.js', function () { + let chai; + + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); + this.afterEach(function() { sandbox.restore(); }); diff --git a/test/unit/uiautomator2-specs.js b/test/unit/uiautomator2-specs.js index 22fe3dfc0..45a03b989 100644 --- a/test/unit/uiautomator2-specs.js +++ b/test/unit/uiautomator2-specs.js @@ -1,5 +1,3 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { ADB } from 'appium-adb'; import { withMocks } from '@appium/test-support'; import { @@ -8,11 +6,11 @@ import { import * as helpers from '../../lib/helpers'; import log from '../../lib/logger'; -chai.should(); -chai.use(chaiAsPromised); describe('UiAutomator2', function () { let uiautomator2; + let chai; + const adb = new ADB(); const serverApk = { 'appPath': 'path/to/appium-uiautomator2-server.apk', @@ -30,6 +28,14 @@ describe('UiAutomator2', function () { disableWindowAnimation: false }; + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + + chai.should(); + chai.use(chaiAsPromised.default); + }); + describe('shouldUninstallServerPackages', function () { beforeEach(function () { uiautomator2 = new UiAutomator2Server(log, {