Skip to content

Commit

Permalink
chore: Bump chai and chai-as-promised (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Jun 21, 2024
1 parent 01f3dbd commit e6d8481
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 88 deletions.
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,20 @@
"@semantic-release/git": "^10.0.1",
"@types/async-lock": "^1.4.0",
"@types/bluebird": "^3.5.38",
"@types/chai": "^4.3.5",
"@types/chai-as-promised": "^7.1.5",
"@types/ini": "^4.1.0",
"@types/lodash": "^4.14.195",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.5",
"@types/semver": "^7.5.0",
"@types/sinon": "^17.0.0",
"@types/source-map-support": "^0.5.6",
"@types/teen_process": "^2.0.0",
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"chai": "^5.1.1",
"chai-as-promised": "^8.0.0",
"conventional-changelog-conventionalcommits": "^8.0.0",
"mocha": "^10.0.0",
"prettier": "^3.0.0",
"rimraf": "^5.0.0",
"semantic-release": "^24.0.0",
"sinon": "^18.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.4.2"
},
Expand Down
16 changes: 9 additions & 7 deletions test/functional/adb-commands-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import path from 'path';
Expand All @@ -8,11 +6,6 @@ import { fs, tempDir } from '@appium/support';
import _ from 'lodash';
import { waitForCondition } from 'asyncbox';


chai.should();
chai.use(chaiAsPromised);
const expect = chai.expect;

const DEFAULT_IMES = [
'com.android.inputmethod.latin/.LatinIME',
'com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME',
Expand All @@ -27,8 +20,17 @@ describe('adb commands', function () {
this.timeout(MOCHA_TIMEOUT);

let adb;
let chai;
let expect;
const androidInstallTimeout = 90000;
before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);
expect = chai.expect;

adb = await ADB.createADB({ adbExecTimeout: 60000 });
});
it('getApiLevel should get correct api level', async function () {
Expand Down
16 changes: 11 additions & 5 deletions test/functional/adb-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import _ from 'lodash';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import { fs } from '@appium/support';
import path from 'path';

const should = chai.should();
chai.use(chaiAsPromised);

describe('ADB', function () {
let chai;
let should;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
chai.use(chaiAsPromised.default);
});

it('should correctly return adb if present', async function () {
let adb = await ADB.createADB();
should.exist(adb.executable.path);
Expand Down
13 changes: 8 additions & 5 deletions test/functional/adb-emu-commands-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';

chai.use(chaiAsPromised);
chai.should();

describe('adb emu commands', function () {
let adb;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);

if (process.env.REAL_DEVICE) {
return this.skip();
}
Expand Down
12 changes: 8 additions & 4 deletions test/functional/android-manifest-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import path from 'path';
Expand All @@ -14,11 +12,17 @@ const tmpDir = path.resolve(__dirname, '..', 'temp');
const srcManifest = path.resolve(__dirname, '..', 'fixtures', 'selendroid', 'AndroidManifest.xml');
const serverPath = path.resolve(__dirname, '..', 'fixtures', 'selendroid', 'selendroid.apk');

chai.use(chaiAsPromised);

describe('Android-manifest', function () {
let adb;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);

adb = await ADB.createADB();
});
it('packageAndLaunchActivityFromManifest should parse package and Activity', async function () {
Expand Down
11 changes: 7 additions & 4 deletions test/functional/apk-signing-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import path from 'path';
Expand All @@ -14,12 +12,17 @@ const tmp = os.tmpdir();
const keystorePath = path.resolve(fixturesRoot, 'appiumtest.keystore');
const keyAlias = 'appiumtest';

chai.use(chaiAsPromised);

describe('Apk-signing', function () {
let adb;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);

adb = await ADB.createADB();
});
it('checkApkCert should return false for unsigned apk', async function () {
Expand Down
13 changes: 8 additions & 5 deletions test/functional/apk-utils-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import path from 'path';
Expand All @@ -10,13 +8,12 @@ const START_APP_WAIT_DURATION = 60000;
const START_APP_WAIT_DURATION_FAIL = process.env.CI ? 20000 : 10000;
const CONTACT_MANAGER_APP_ID = 'com.example.android.contactmanager';

chai.should();
chai.use(chaiAsPromised);

describe('apk utils', function () {
this.timeout(MOCHA_TIMEOUT);

let adb;
let chai;

const contactManagerPath = path.resolve(__dirname, '..', 'fixtures', 'ContactManager.apk');
const apiDemosPath = path.resolve(__dirname, '..', 'fixtures', 'ApiDemos-debug.apk');
const deviceTempPath = '/data/local/tmp/';
Expand All @@ -27,6 +24,12 @@ describe('apk utils', function () {
};

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);

adb = await ADB.createADB({
adbExecTimeout: process.env.CI ? 60000 : 40000,
});
Expand Down
14 changes: 10 additions & 4 deletions test/functional/helpers-specs-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { getAndroidPlatformAndPath, requireSdkRoot } from '../../lib/helpers.js';

chai.use(chaiAsPromised);

describe('Helpers', function () {
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);
});

it('getAndroidPlatformAndPath should return platform and path for android', async function () {
const sdkRoot = await requireSdkRoot();
const {platform, platformPath} = await getAndroidPlatformAndPath(sdkRoot);
Expand Down
13 changes: 9 additions & 4 deletions test/functional/lock-mgmt-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';

chai.use(chaiAsPromised);

describe('Lock Management', function () {
let adb;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);
});

before(async function () {
adb = await ADB.createADB();
Expand Down
14 changes: 8 additions & 6 deletions test/functional/logcat-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import Logcat from '../../lib/logcat';
import { MOCHA_TIMEOUT } from './setup';


chai.use(chaiAsPromised);
chai.should();

describe('logcat', function () {
this.timeout(MOCHA_TIMEOUT);

Expand All @@ -26,7 +20,15 @@ describe('logcat', function () {

let adb;
let logcat;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);

adb = await ADB.createADB();
});
afterEach(async function () {
Expand Down
12 changes: 8 additions & 4 deletions test/functional/syscalls-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import { apiLevel, avdName, MOCHA_TIMEOUT, MOCHA_LONG_TIMEOUT } from './setup';
Expand All @@ -10,13 +8,19 @@ import _ from 'lodash';

const DEFAULT_CERTIFICATE = path.join('keys', 'testkey.x509.pem');

chai.use(chaiAsPromised);

describe('System calls', function () {
this.timeout(MOCHA_TIMEOUT);

let adb;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);

adb = await ADB.createADB();
});
it('getConnectedDevices should get devices', async function () {
Expand Down
19 changes: 13 additions & 6 deletions test/unit/adb-commands-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import net from 'net';
Expand All @@ -9,10 +7,6 @@ import { withMocks } from '@appium/test-support';
import _ from 'lodash';
import { EOL } from 'os';


chai.use(chaiAsPromised);
const expect = chai.expect;
const should = chai.should();
const apiLevel = 21,
platformVersion = '4.4.4',
language = 'en',
Expand Down Expand Up @@ -44,6 +38,19 @@ const logcat = new Logcat({
});

describe('adb commands', withMocks({adb, logcat, teen_process, net}, function (mocks) {
let chai;
let should;
let expect;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
expect = chai.expect;
chai.use(chaiAsPromised.default);
});

afterEach(function () {
mocks.verify();
});
Expand Down
15 changes: 10 additions & 5 deletions test/unit/adb-emu-commands-specs.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import {ADB} from '../../lib/adb';
import { withMocks } from '@appium/test-support';
import _ from 'lodash';

chai.use(chaiAsPromised);
chai.should();

const emulators = [
{ udid: 'emulator-5554', state: 'device', port: 5554 },
{ udid: 'emulator-5556', state: 'device', port: 5556 },
Expand All @@ -17,6 +12,16 @@ const fingerprintId = 1111;
const adb = new ADB();

describe('adb emulator commands', withMocks({adb}, function (mocks) {
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);
});

afterEach(function () {
mocks.verify();
});
Expand Down
14 changes: 10 additions & 4 deletions test/unit/adb-specs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-unresolved
import { ADB, DEFAULT_ADB_PORT } from '../../lib/adb';


chai.use(chaiAsPromised);

describe('ADB', function () {
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

chai.should();
chai.use(chaiAsPromised.default);
});

describe('clone', function () {
it('should copy all options', function () {
const original = new ADB({
Expand Down
Loading

0 comments on commit e6d8481

Please sign in to comment.