Skip to content

Commit cf006a5

Browse files
chore: Drop chai
1 parent 169c031 commit cf006a5

35 files changed

Lines changed: 478 additions & 499 deletions

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,13 @@
7777
"@appium/support": "^7.0.0-rc.1",
7878
"@appium/tsconfig": "^1.2.0",
7979
"@appium/types": "^1.5.0",
80-
"@types/chai": "^5.2.3",
81-
"@types/chai-as-promised": "^8.0.2",
8280
"@types/node": "^26.0.0",
8381
"@types/portscanner": "^2.1.1",
8482
"@types/semver": "^7.5.0",
8583
"@types/sinon": "^22.0.0",
8684
"@types/unzipper": "^0.10.11",
8785
"@types/ws": "^8.5.4",
8886
"@xmldom/xmldom": "^0.x",
89-
"chai": "^6.0.0",
90-
"chai-as-promised": "^8.0.0",
9187
"sharp": "^0.x",
9288
"sinon": "^22.0.0",
9389
"unzipper": "^0.x",

test/functional/commands/file-movement-e2e-specs.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1+
import assert from 'node:assert/strict';
12
import stream from 'node:stream';
23
import {describe, it, before, after} from 'node:test';
34

4-
import {expect, use} from 'chai';
5-
import chaiAsPromised from 'chai-as-promised';
65
import unzipper from 'unzipper';
76
import type {Browser} from 'webdriverio';
87

98
import {APIDEMOS_CAPS} from '../desired.js';
109
import {initSession, deleteSession} from '../helpers/session.js';
1110

12-
use(chaiAsPromised);
13-
1411
describe('file movement', function () {
1512
let driver: Browser;
1613

@@ -35,7 +32,7 @@ describe('file movement', function () {
3532
// get the file and its contents, to check
3633
const remoteData64 = await driver.pullFile(remotePath);
3734
const remoteData = Buffer.from(remoteData64, 'base64').toString();
38-
expect(remoteData).to.equal(stringData);
35+
assert.strictEqual(remoteData, stringData);
3936
});
4037

4138
it('should pull a folder', async function () {
@@ -71,6 +68,6 @@ describe('file movement', function () {
7168
zipStream.push(null);
7269
});
7370

74-
expect(await zipPromise).to.equal(2);
71+
assert.strictEqual(await zipPromise, 2);
7572
});
7673
});
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
import assert from 'node:assert/strict';
12
import {describe, it, before, after} from 'node:test';
23

3-
import {expect, use} from 'chai';
4-
import chaiAsPromised from 'chai-as-promised';
54
import type {Browser} from 'webdriverio';
65

76
import {APIDEMOS_CAPS} from '../../desired.js';
87
import {initSession, deleteSession} from '../../helpers/session.js';
98

10-
use(chaiAsPromised);
11-
129
describe('Find - accessibility ID', function () {
1310
let driver: Browser;
1411

@@ -19,14 +16,14 @@ describe('Find - accessibility ID', function () {
1916
await deleteSession();
2017
});
2118
it('should find an element by name', async function () {
22-
await expect(driver.$('~Animation').elementId).to.eventually.exist;
19+
assert.ok((await driver.$('~Animation').elementId) != null);
2320
});
2421
it('should return an array of one element with findElements', async function () {
2522
const els = await driver.$$('~Animation');
26-
expect(els).to.be.an.instanceof(Array);
27-
expect(els).to.have.length(1);
23+
assert.ok(Array.isArray(els));
24+
assert.strictEqual(els.length, 1);
2825
});
2926
it('should find an element with a content-desc property containing an apostrophe', async function () {
30-
await expect(driver.$("~Access'ibility").elementId).to.eventually.exist;
27+
assert.ok((await driver.$("~Access'ibility").elementId) != null);
3128
});
3229
});
Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
import assert from 'node:assert/strict';
12
import {describe, it, before, after} from 'node:test';
23

3-
import {expect, use} from 'chai';
4-
import chaiAsPromised from 'chai-as-promised';
54
import type {Browser} from 'webdriverio';
65

76
import {APIDEMOS_CAPS} from '../../desired.js';
87
import {initSession, deleteSession} from '../../helpers/session.js';
98

10-
use(chaiAsPromised);
11-
129
describe('Find - CSS', function () {
1310
let driver: Browser;
1411
before(async function () {
@@ -18,56 +15,56 @@ describe('Find - CSS', function () {
1815
await deleteSession();
1916
});
2017
it('should find an element by id (android resource-id)', async function () {
21-
await expect(driver.$('#android\\:id\\/text1').elementId).to.eventually.exist;
22-
await expect(driver.$('*[id="android:id/text1"]').elementId).to.eventually.exist;
23-
await expect(driver.$('*[resource-id="android:id/text1"]').elementId).to.eventually.exist;
18+
assert.ok((await driver.$('#android\\:id\\/text1').elementId) != null);
19+
assert.ok((await driver.$('*[id="android:id/text1"]').elementId) != null);
20+
assert.ok((await driver.$('*[resource-id="android:id/text1"]').elementId) != null);
2421
});
2522
it('should find an element by content description', async function () {
26-
await expect(driver.$('*[description="Animation"]').elementId).to.eventually.exist;
23+
assert.ok((await driver.$('*[description="Animation"]').elementId) != null);
2724
});
2825
it('should return an array with findElements', async function () {
2926
const els = await driver.$$('*[content-desc="Animation"]');
30-
expect(els).to.be.an.instanceof(Array);
31-
expect(els).to.have.length(1);
27+
assert.ok(Array.isArray(els));
28+
assert.strictEqual(els.length, 1);
3229
});
3330
it('should find an element with a content-desc property containing an apostrophe', async function () {
34-
await expect(driver.$('*[content-description="Access\'ibility"]').elementId).to.eventually.exist;
31+
assert.ok((await driver.$('*[content-description="Access\'ibility"]').elementId) != null);
3532
});
3633
it('should find an element by class name', async function () {
3734
const el = await driver.$('android.widget.TextView');
3835
const text = await el.getText();
39-
expect(text.toLowerCase()).to.equal('api demos');
36+
assert.strictEqual(text.toLowerCase(), 'api demos');
4037
});
4138
it.skip('should find an element with a chain of attributes and pseudo-classes', async function () {
4239
// TODO: webdriver selects 'class name' strategy.
4340
// ref. https://github.com/webdriverio/webdriverio/blob/eba541a77dbc42173717e1c106a7c4d3ccb198f5/packages/webdriverio/src/utils/findStrategy.ts#L91-L96
4441
const el = await driver.$('android.widget.TextView[clickable=true]:nth-child(1)');
45-
await expect(el.getText()).to.eventually.equal('Accessibility');
42+
assert.strictEqual(await el.getText(), 'Accessibility');
4643
});
4744
it('should find an element with recursive UiSelectors', async function () {
4845
const els = await driver.$$('*[focused=true] *[clickable=true]');
49-
expect(els).to.have.length(1);
46+
assert.strictEqual(els.length, 1);
5047
});
5148
it('should find an element by a non-fully qualified class name using CSS tag name', async function () {
5249
const els = await driver.$$('android.widget.TextView');
53-
expect(els.length).to.be.above(0);
50+
assert.ok((await els.length) > 0);
5451
});
5552
it('should find elements using starts with attribute', async function () {
56-
await expect(driver.$('*[description^="Animation"]').elementId).to.eventually.exist;
53+
assert.ok((await driver.$('*[description^="Animation"]').elementId) != null);
5754
});
5855
it('should find elements using ends with attribute', async function () {
59-
await expect(driver.$('*[description$="Animation"]').elementId).to.eventually.exist;
56+
assert.ok((await driver.$('*[description$="Animation"]').elementId) != null);
6057
});
6158
it('should find elements using word match attribute', async function () {
62-
await expect(driver.$('*[description~="Animation"]').elementId).to.eventually.exist;
59+
assert.ok((await driver.$('*[description~="Animation"]').elementId) != null);
6360
});
6461
it('should find elements using wildcard attribute', async function () {
65-
await expect(driver.$('*[description*="Animation"]').elementId).to.eventually.exist;
62+
assert.ok((await driver.$('*[description*="Animation"]').elementId) != null);
6663
});
6764
it('should allow UiScrollable with unicode string', async function () {
6865
await driver.startActivity('io.appium.android.apis', '.text.Unicode');
6966
const selector = '*[text="عربي"]:instance(0)';
7067
const el = await driver.$(selector);
71-
await expect(el.getText()).to.eventually.equal('عربي');
68+
assert.strictEqual(await el.getText(), 'عربي');
7269
});
7370
});
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
import assert from 'node:assert/strict';
12
import {describe, it, before, after} from 'node:test';
23

3-
import {expect, use} from 'chai';
4-
import chaiAsPromised from 'chai-as-promised';
54
import type {Browser} from 'webdriverio';
65

76
import {APIDEMOS_CAPS} from '../../desired.js';
87
import {initSession, deleteSession} from '../../helpers/session.js';
98

10-
use(chaiAsPromised);
11-
129
describe('Find - ID', function () {
1310
let driver: Browser;
1411

@@ -19,11 +16,11 @@ describe('Find - ID', function () {
1916
await deleteSession();
2017
});
2118
it('should find an element by id', async function () {
22-
await expect(driver.$('id=android:id/text1').elementId).to.eventually.exist;
19+
assert.ok((await driver.$('id=android:id/text1').elementId) != null);
2320
});
2421
it('should return an array of one element with findElements', async function () {
2522
const els = await driver.$$('id=android:id/text1');
26-
expect(els).to.be.an.instanceof(Array);
27-
expect(els).to.have.length.above(1);
23+
assert.ok(Array.isArray(els));
24+
assert.ok(els.length > 1);
2825
});
2926
});

test/functional/commands/find/by-image-e2e-specs.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1+
import assert from 'node:assert/strict';
12
import path from 'node:path';
23
import {describe, it, before, after} from 'node:test';
34
import {fileURLToPath} from 'node:url';
45

56
import {node} from 'appium/support.js';
67
import {sleep} from 'asyncbox';
7-
import {expect, use} from 'chai';
8-
import chaiAsPromised from 'chai-as-promised';
98
import type {Browser} from 'webdriverio';
109

1110
import {APIDEMOS_CAPS, amendCapabilities} from '../../desired.js';
1211
import {initSession, deleteSession} from '../../helpers/session.js';
1312

14-
use(chaiAsPromised);
15-
1613
const MODULE_NAME = 'appium-uiautomator2-driver';
1714
const FILENAME = fileURLToPath(import.meta.url);
1815
const MODULE_ROOT = node.getModuleRootSync(MODULE_NAME, FILENAME);
@@ -47,34 +44,36 @@ describe('Find - Image', {skip: true}, function () {
4744

4845
it('should find image elements', async function () {
4946
const els = await driver.$$(START_IMG);
50-
expect(els).to.have.length(1);
47+
assert.strictEqual(els.length, 1);
5148
});
5249
it('should find an image element', async function () {
5350
const el = await driver.$(START_IMG);
5451
const value = await el.getValue();
55-
expect(value).to.match(/appium-image-element/);
52+
assert.match(value, /appium-image-element/);
5653
});
5754
it('should not find an image element that is not matched', async function () {
58-
await expect(driver.$(SQUARES_IMG)).to.eventually.be.rejectedWith(/Error response status: 7/);
55+
await assert.rejects(async () => {
56+
await driver.$(SQUARES_IMG);
57+
}, /Error response status: 7/);
5958
});
6059
it('should find anything with a threshold low enough', async function () {
6160
const {imageMatchThreshold} = await driver.getSettings();
6261
await driver.updateSettings({imageMatchThreshold: 0});
6362
try {
64-
await expect(driver.$(SQUARES_IMG).elementId).to.eventually.exist;
63+
assert.ok((await driver.$(SQUARES_IMG).elementId) != null);
6564
} finally {
6665
await driver.updateSettings({imageMatchThreshold});
6766
}
6867
});
6968
it('should be able to get basic element properties', async function () {
7069
const el = await driver.$(START_IMG);
71-
await expect(el.isDisplayed()).to.eventually.be.true;
70+
assert.strictEqual(await el.isDisplayed(), true);
7271
const size = await el.getSize();
73-
expect(size.width).to.be.above(0);
74-
expect(size.height).to.be.above(0);
72+
assert.ok(size.width > 0);
73+
assert.ok(size.height > 0);
7574
const loc = await el.getLocation();
76-
expect(loc.x).to.be.at.least(0);
77-
expect(loc.y).to.be.at.least(0);
75+
assert.ok(loc.x >= 0);
76+
assert.ok(loc.y >= 0);
7877
// TODO: getLocationInView requires an argument - skipping for now
7978
// const locInView = await el.getLocationInView();
8079
// expect(locInView.x).to.eql(loc.x);
@@ -89,7 +88,7 @@ describe('Find - Image', {skip: true}, function () {
8988
const text = await readout.getText();
9089
const match = /Initial format: \d\d:(\d\d)/.exec(text);
9190
const secs = parseInt(match![1], 10);
92-
expect(secs).to.be.above(2);
93-
expect(secs).to.be.below(20);
91+
assert.ok(secs > 2);
92+
assert.ok(secs < 20);
9493
});
9594
});

0 commit comments

Comments
 (0)