Skip to content

Commit 11ba27c

Browse files
chore: Drop mocha and chai (#1169)
1 parent c115db0 commit 11ba27c

6 files changed

Lines changed: 131 additions & 148 deletions

File tree

.mocharc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"format:check": "prettier --check ./lib ./test",
1515
"prepare": "npm run build",
1616
"version": "npm run sync-wda-version",
17-
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.ts\"",
18-
"e2e-test": "mocha --exit --timeout 10m \"./test/functional/**/*-specs.ts\"",
17+
"test": "node --test --test-timeout=60000 \"./build/test/unit/**/*.spec.js\"",
18+
"e2e-test": "node --test --test-force-exit --test-concurrency=1 --test-timeout=600000 \"./build/test/functional/**/*.spec.js\"",
1919
"bundle": "npm run bundle:ios && npm run bundle:tv",
2020
"bundle:ios": "TARGET=runner SDK=sim node ./Scripts/build-webdriveragent.mjs",
2121
"bundle:tv": "TARGET=tv_runner SDK=tv_sim node ./Scripts/build-webdriveragent.mjs",
@@ -55,22 +55,15 @@
5555
"@semantic-release/changelog": "^6.0.1",
5656
"@semantic-release/git": "^10.0.1",
5757
"@types/async-lock": "^1.4.2",
58-
"@types/chai": "^5.2.3",
59-
"@types/chai-as-promised": "^8.0.2",
60-
"@types/mocha": "^10.0.1",
6158
"@types/node": "^26.0.0",
6259
"@types/sinon": "^22.0.0",
6360
"appium-xcode": "^6.0.0",
64-
"chai": "^6.0.0",
65-
"chai-as-promised": "^8.0.0",
6661
"conventional-changelog-conventionalcommits": "^9.3.1",
67-
"mocha": "^11.0.1",
6862
"node-simctl": "^8.0.0",
6963
"prettier": "^3.9.3",
7064
"semantic-release": "^25.0.2",
7165
"semver": "^7.3.7",
7266
"sinon": "^22.0.0",
73-
"ts-node": "^10.9.1",
7467
"typescript": "^6.0.2"
7568
},
7669
"dependencies": {

test/functional/webdriveragent-e2e-specs.ts renamed to test/functional/webdriveragent-e2e.spec.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import chai, {expect} from 'chai';
2-
import chaiAsPromised from 'chai-as-promised';
31
import {Simctl} from 'node-simctl';
42
import {getSimulator} from 'appium-ios-simulator';
53
import {killAllSimulators, shutdownSimulator} from './helpers/simulator';
@@ -9,15 +7,13 @@ import {retryInterval} from 'asyncbox';
97
import {WebDriverAgent} from '../../lib/webdriveragent';
108
import axios from 'axios';
119
import type {AppleDevice} from '../../lib/types';
12-
13-
chai.use(chaiAsPromised);
10+
import {describe, before, after, beforeEach, afterEach, it} from 'node:test';
11+
import assert from 'node:assert/strict';
1412

1513
type SimulatorTestDevice = AppleDevice & {simctl: Simctl};
1614

17-
const MOCHA_TIMEOUT_MS = 60 * 1000 * 5;
18-
1915
const SIM_DEVICE_NAME = 'webDriverAgentTest';
20-
const SIM_STARTUP_TIMEOUT_MS = MOCHA_TIMEOUT_MS;
16+
const SIM_STARTUP_TIMEOUT_MS = 60 * 1000 * 5;
2117

2218
const testUrl = 'http://localhost:8100/tree';
2319

@@ -34,8 +30,6 @@ function getStartOpts(device: AppleDevice) {
3430
}
3531

3632
describe('WebDriverAgent', function () {
37-
this.timeout(MOCHA_TIMEOUT_MS);
38-
3933
describe('with fresh sim', function () {
4034
let device: SimulatorTestDevice;
4135
let simctl: Simctl;
@@ -58,15 +52,12 @@ describe('WebDriverAgent', function () {
5852
});
5953

6054
after(async function () {
61-
this.timeout(MOCHA_TIMEOUT_MS);
62-
6355
await shutdownSimulator(device);
6456

6557
await simctl.deleteDevice();
6658
});
6759

6860
describe('with running sim', function () {
69-
this.timeout(6 * 60 * 1000);
7061
beforeEach(async function () {
7162
await killAllSimulators();
7263
await device.simctl.startBootMonitor({
@@ -86,14 +77,11 @@ describe('WebDriverAgent', function () {
8677
const agent = new WebDriverAgent(getStartOpts(device));
8778

8879
await agent.launch('sessionId');
89-
await expect(axios({url: testUrl})).to.be.rejected;
80+
await assert.rejects(() => axios({url: testUrl}), /Request failed with status code 404/);
9081
await agent.quit();
9182
});
9283

9384
it('should fail if xcodebuild fails', async function () {
94-
// short timeout
95-
this.timeout(35 * 1000);
96-
9785
const agent = new WebDriverAgent(getStartOpts(device));
9886
(agent.xcodebuild as any).createSubProcess = async function () {
9987
const args = [
@@ -108,7 +96,7 @@ describe('WebDriverAgent', function () {
10896
return new SubProcess('xcodebuild', args, {detached: true});
10997
};
11098

111-
await expect(agent.launch('sessionId')).to.be.rejectedWith('xcodebuild failed');
99+
await assert.rejects(() => agent.launch('sessionId'), /xcodebuild failed/);
112100

113101
await agent.quit();
114102
});
Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import chai, {expect} from 'chai';
2-
import chaiAsPromised from 'chai-as-promised';
1+
import assert from 'node:assert/strict';
32
import {getXctestrunFilePath, getAdditionalRunContent, getXctestrunFileName} from '../../lib/utils';
43
import {PLATFORM_NAME_IOS, PLATFORM_NAME_TVOS} from '../../lib/constants';
54
import {fs} from '@appium/support';
@@ -8,8 +7,7 @@ import {fail} from 'node:assert';
87
import {arch} from 'node:os';
98
import sinon from 'sinon';
109
import type {DeviceInfo} from '../../lib/types';
11-
12-
chai.use(chaiAsPromised);
10+
import {describe, beforeEach, afterEach, it} from 'node:test';
1311

1412
function get_arch(): string {
1513
return arch() === 'arm64' ? 'arm64' : 'x86_64';
@@ -39,7 +37,8 @@ describe('utils', function () {
3937
.resolves(true);
4038
sandbox.stub(fs, 'copyFile');
4139
const deviceInfo: DeviceInfo = {isRealDevice: true, udid, platformVersion, platformName};
42-
await expect(getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath)).to.eventually.equal(
40+
assert.strictEqual(
41+
await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath),
4342
path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`),
4443
);
4544
sandbox.assert.notCalled(fs.copyFile as any);
@@ -72,7 +71,8 @@ describe('utils', function () {
7271
platformVersion,
7372
platformName: PLATFORM_NAME_IOS,
7473
};
75-
await expect(getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath)).to.eventually.equal(
74+
assert.strictEqual(
75+
await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath),
7676
path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`),
7777
);
7878
});
@@ -99,7 +99,8 @@ describe('utils', function () {
9999
platformVersion,
100100
platformName: PLATFORM_NAME_IOS,
101101
};
102-
await expect(getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath)).to.eventually.equal(
102+
assert.strictEqual(
103+
await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath),
103104
path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`),
104105
);
105106
sandbox.assert.notCalled(fs.copyFile as any);
@@ -143,7 +144,8 @@ describe('utils', function () {
143144
platformVersion,
144145
platformName: PLATFORM_NAME_IOS,
145146
};
146-
await expect(getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath)).to.eventually.equal(
147+
assert.strictEqual(
148+
await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath),
147149
path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`),
148150
);
149151
});
@@ -164,7 +166,8 @@ describe('utils', function () {
164166
await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath);
165167
fail();
166168
} catch (err: any) {
167-
expect(err.message).to.equal(
169+
assert.strictEqual(
170+
err.message,
168171
`If you are using 'useXctestrunFile' capability then you need to have a xctestrun file (expected: '${expected}')`,
169172
);
170173
}
@@ -174,19 +177,20 @@ describe('utils', function () {
174177
describe('#getAdditionalRunContent', function () {
175178
it('should return ios format', function () {
176179
const wdaPort = getAdditionalRunContent(PLATFORM_NAME_IOS, 8000);
177-
expect(wdaPort.WebDriverAgentRunner.EnvironmentVariables.USE_PORT).to.equal('8000');
180+
assert.strictEqual(wdaPort.WebDriverAgentRunner.EnvironmentVariables.USE_PORT, '8000');
178181
});
179182

180183
it('should return tvos format', function () {
181184
const wdaPort = getAdditionalRunContent(PLATFORM_NAME_TVOS, '9000');
182-
expect(wdaPort.WebDriverAgentRunner_tvOS.EnvironmentVariables.USE_PORT).to.equal('9000');
185+
assert.strictEqual(wdaPort.WebDriverAgentRunner_tvOS.EnvironmentVariables.USE_PORT, '9000');
183186
});
184187

185188
it('should include max HTTP request body size if provided', function () {
186189
const runContent = getAdditionalRunContent(PLATFORM_NAME_IOS, 8000, undefined, 1024);
187-
expect(
190+
assert.strictEqual(
188191
runContent.WebDriverAgentRunner.EnvironmentVariables.MAX_HTTP_REQUEST_BODY_SIZE,
189-
).to.equal('1024');
192+
'1024',
193+
);
190194
});
191195
});
192196

@@ -198,7 +202,8 @@ describe('utils', function () {
198202
const platformName = 'iOs';
199203
const deviceInfo: DeviceInfo = {isRealDevice: true, udid, platformVersion, platformName};
200204

201-
expect(getXctestrunFileName(deviceInfo, '10.2.0')).to.equal(
205+
assert.strictEqual(
206+
getXctestrunFileName(deviceInfo, '10.2.0'),
202207
'WebDriverAgentRunner_iphoneos10.2.0-arm64.xctestrun',
203208
);
204209
});
@@ -207,7 +212,8 @@ describe('utils', function () {
207212
const platformName = 'ios';
208213
const deviceInfo: DeviceInfo = {isRealDevice: false, udid, platformVersion, platformName};
209214

210-
expect(getXctestrunFileName(deviceInfo, '10.2.0')).to.equal(
215+
assert.strictEqual(
216+
getXctestrunFileName(deviceInfo, '10.2.0'),
211217
`WebDriverAgentRunner_iphonesimulator10.2.0-${get_arch()}.xctestrun`,
212218
);
213219
});
@@ -216,7 +222,8 @@ describe('utils', function () {
216222
const platformName = 'tVos';
217223
const deviceInfo: DeviceInfo = {isRealDevice: true, udid, platformVersion, platformName};
218224

219-
expect(getXctestrunFileName(deviceInfo, '10.2.0')).to.equal(
225+
assert.strictEqual(
226+
getXctestrunFileName(deviceInfo, '10.2.0'),
220227
'WebDriverAgentRunner_tvOS_appletvos10.2.0-arm64.xctestrun',
221228
);
222229
});
@@ -225,7 +232,8 @@ describe('utils', function () {
225232
const platformName = 'tvOS';
226233
const deviceInfo: DeviceInfo = {isRealDevice: false, udid, platformVersion, platformName};
227234

228-
expect(getXctestrunFileName(deviceInfo, '10.2.0')).to.equal(
235+
assert.strictEqual(
236+
getXctestrunFileName(deviceInfo, '10.2.0'),
229237
`WebDriverAgentRunner_tvOS_appletvsimulator10.2.0-${get_arch()}.xctestrun`,
230238
);
231239
});

0 commit comments

Comments
 (0)