Skip to content

Commit

Permalink
chore: Bump chai and chai-as-promised (#2414)
Browse files Browse the repository at this point in the history
* bump chai

* ignoer ts lint

* update tests and remove unnecessary dependencies
  • Loading branch information
KazuCocoa authored Jun 27, 2024
1 parent 345604a commit 6ba1b5e
Show file tree
Hide file tree
Showing 49 changed files with 620 additions and 424 deletions.
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,14 @@
"@semantic-release/changelog": "^6.0.3",
"@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.196",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.7",
"@types/portscanner": "^2.1.1",
"@types/sinon": "^17.0.0",
"@types/sinon-chai": "^3.2.9",
"@types/teen_process": "^2.0.1",
"axios": "^1.4.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
"chai": "^5.1.1",
"chai-as-promised": "^8.0.0",
"conventional-changelog-conventionalcommits": "^8.0.0",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.1",
Expand All @@ -166,7 +161,6 @@
"semantic-release": "^24.0.0",
"sharp": "^0.x",
"sinon": "^18.0.0",
"sinon-chai": "^3.7.0",
"ts-node": "^10.9.1",
"type-fest": "^4.1.0",
"typescript": "^5.4.2",
Expand Down
12 changes: 8 additions & 4 deletions test/functional/basic/alert-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import B from 'bluebird';
import {retryInterval} from 'asyncbox';
import {amendCapabilities, UICATALOG_CAPS} from '../desired';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';

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

describe('XCUITestDriver - alerts -', function () {
this.timeout(MOCHA_TIMEOUT);

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(UICATALOG_CAPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
});
Expand Down
18 changes: 11 additions & 7 deletions test/functional/basic/basic-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import chaiSubset from 'chai-subset';
import B from 'bluebird';
import util from 'util';
import {retryInterval} from 'asyncbox';
Expand All @@ -9,15 +6,20 @@ import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '
import {GUINEA_PIG_PAGE} from '../web/helpers';
import sharp from 'sharp';

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

describe('XCUITestDriver - basics -', function () {
this.timeout(MOCHA_TIMEOUT);

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(UICATALOG_CAPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
});
Expand Down Expand Up @@ -144,7 +146,9 @@ describe('XCUITestDriver - basics -', function () {
it('should get the list of available logs', async function () {
const expectedTypes = ['syslog', 'crashlog', 'performance', 'server', 'safariConsole'];
const actualTypes = await driver.getLogTypes();
actualTypes.should.containSubset(expectedTypes);
for (const actualType of actualTypes) {
expectedTypes.includes(actualType).should.be.true;
}
});
});

Expand Down
12 changes: 8 additions & 4 deletions test/functional/basic/element-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import _ from 'lodash';
import B from 'bluebird';
import {retryInterval} from 'asyncbox';
import {extractCapabilityValue, amendCapabilities, UICATALOG_CAPS} from '../desired';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';
import {util} from 'appium/support';

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

describe('XCUITestDriver - elements -', function () {
this.timeout(MOCHA_TIMEOUT);

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(UICATALOG_CAPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
});
Expand Down
16 changes: 11 additions & 5 deletions test/functional/basic/face-id-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {amendCapabilities, FACEIDAPP_CAPS} from '../desired';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';
import B from 'bluebird';
import {killAllSimulators} from '../helpers/simulator';
import {CLASS_CHAIN_SEARCH} from '../helpers/element';
import {waitForCondition} from 'asyncbox';

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

const DEFAULT_IMPLICIT_TIMEOUT_MS = 1000;
const FACE_ID_SELECTOR = '**/XCUIElementTypeStaticText[`label == "Face ID"`]';
Expand All @@ -26,6 +21,17 @@ if (!process.env.CI) {
this.timeout(MOCHA_TIMEOUT * 2);
this.retries(MOCHA_RETRIES);
let driver;
let chai;
let expect;

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

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

beforeEach(async function () {
await killAllSimulators();
Expand Down
13 changes: 9 additions & 4 deletions test/functional/basic/find-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';
import B from 'bluebird';
import _ from 'lodash';
import {retryInterval} from 'asyncbox';
Expand All @@ -13,8 +11,6 @@ import {PREDICATE_SEARCH, CLASS_CHAIN_SEARCH} from '../helpers/element';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';
import {util} from 'appium/support';

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

const TEST_PAUSE_DURATION = 500;

Expand All @@ -28,7 +24,16 @@ describe('XCUITestDriver - find -', function () {
this.timeout(MOCHA_TIMEOUT);

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(UICATALOG_CAPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
});
Expand Down
13 changes: 9 additions & 4 deletions test/functional/basic/gesture-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import B from 'bluebird';
import {retryInterval} from 'asyncbox';
import {UICATALOG_CAPS, amendCapabilities} from '../desired';
import {PREDICATE_SEARCH} from '../helpers/element';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';
import {APPIUM_IMAGE} from '../web/helpers';

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

const BTN_OK_CNCL = 'Okay / Cancel';

describe('XCUITestDriver - gestures', function () {
this.timeout(MOCHA_TIMEOUT);

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('dynamic gestures', function () {
before(async function () {
Expand Down
17 changes: 12 additions & 5 deletions test/functional/basic/touch-id-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {amendCapabilities, TOUCHIDAPP_CAPS} from '../desired';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';
import B from 'bluebird';
import {killAllSimulators} from '../helpers/simulator';
import {CLASS_CHAIN_SEARCH} from '../helpers/element';
import {waitForCondition} from 'asyncbox';

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

const DEFAULT_IMPLICIT_TIMEOUT_MS = 1000;
const TOUCH_ID_SELECTOR = '**/XCUIElementTypeStaticText[`label == "Touch ID for “biometric”"`]';
Expand All @@ -23,6 +18,18 @@ if (!process.env.CI) {
this.timeout(MOCHA_TIMEOUT * 2);
this.retries(MOCHA_RETRIES);
let driver;
let chai;
let expect;

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

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

expect = chai.expect;
});

beforeEach(async function () {
await killAllSimulators();
Expand Down
14 changes: 10 additions & 4 deletions test/functional/device/accessibility-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {PREDICATE_SEARCH} from '../helpers/element';
import {MOCHA_TIMEOUT, initSession, deleteSession, hasDefaultPrebuiltWDA} from '../helpers/session';
import {SETTINGS_CAPS, amendCapabilities} from '../desired';

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

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

let driver, caps;

let chai;

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

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

beforeEach(function () {
caps = amendCapabilities(SETTINGS_CAPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
Expand Down
12 changes: 8 additions & 4 deletions test/functional/device/file-movement-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {amendCapabilities, UICATALOG_CAPS} from '../desired';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';
import {fs, tempDir, zip} from 'appium/support';
import path from 'path';

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

const UICAT_CONTAINER = `@com.example.apple-samplecode.UICatalog`;

Expand All @@ -19,7 +15,15 @@ describe('XCUITestDriver - file movement', function () {
this.timeout(MOCHA_TIMEOUT);

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(UICATALOG_CAPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
});
Expand Down
14 changes: 9 additions & 5 deletions test/functional/device/otherApps-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {MOCHA_TIMEOUT, initSession, deleteSession, hasDefaultPrebuiltWDA} from '../helpers/session';
import {MULTIPLE_APPS, amendCapabilities} from '../desired';

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

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

let caps;

let driver;
before(function () {
let chai;

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

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

caps = amendCapabilities(MULTIPLE_APPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
'appium:wdaStartupRetries': 0,
Expand Down
14 changes: 10 additions & 4 deletions test/functional/device/passwords-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {MOCHA_TIMEOUT, initSession, deleteSession, hasDefaultPrebuiltWDA} from '../helpers/session';
import {UICATALOG_CAPS, amendCapabilities, extractCapabilityValue} from '../desired';
import {util} from 'appium/support';

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

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

let driver, caps;

let chai;

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

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

beforeEach(function () {
caps = amendCapabilities(UICATALOG_CAPS, {
'appium:usePrebuiltWDA': hasDefaultPrebuiltWDA(),
Expand Down
13 changes: 9 additions & 4 deletions test/functional/device/performance-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import B from 'bluebird';
import {amendCapabilities, UICATALOG_CAPS} from '../desired';
import {initSession, deleteSession, hasDefaultPrebuiltWDA, MOCHA_TIMEOUT} from '../helpers/session';

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

describe('XCUITestDriver - performance', function () {
this.timeout(MOCHA_TIMEOUT);
const profileName = 'Time Profiler';

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('record performance metrics', function () {
before(async function () {
Expand Down
Loading

0 comments on commit 6ba1b5e

Please sign in to comment.