Skip to content

Commit 3674f25

Browse files
chore: Drop mocha and chai (#24)
1 parent fff7593 commit 3674f25

5 files changed

Lines changed: 38 additions & 51 deletions

File tree

.mocharc.js

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

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"format": "prettier -w ./lib ./test",
4848
"format:check": "prettier --check ./lib ./test",
4949
"prepare": "npm run build",
50-
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.ts\"",
51-
"e2e-test": "mocha --exit --timeout 5m \"./test/e2e/**/*-specs.ts\""
50+
"test": "node --test --test-timeout=60000 \"./build/test/unit/**/*.spec.js\"",
51+
"e2e-test": "node --test --test-force-exit --test-concurrency=1 --test-timeout=300000 \"./build/test/e2e/**/*.spec.js\""
5252
},
5353
"prettier": {
5454
"bracketSpacing": false,
@@ -61,16 +61,10 @@
6161
"@appium/types": "^1.0.0-rc.1",
6262
"@semantic-release/changelog": "^6.0.1",
6363
"@semantic-release/git": "^10.0.1",
64-
"@types/chai": "^5.2.3",
65-
"@types/mocha": "^10.0.1",
6664
"@types/node": "^25.0.3",
67-
"chai": "^6.0.0",
68-
"chai-as-promised": "^8.0.0",
6965
"conventional-changelog-conventionalcommits": "^9.0.0",
70-
"mocha": "^11.0.1",
7166
"prettier": "^3.0.0",
7267
"semantic-release": "^25.0.2",
73-
"ts-node": "^10.9.1",
7468
"typescript": "^6.0.2"
7569
}
7670
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {expect} from 'chai';
1+
import assert from 'node:assert/strict';
22
import {Devicectl} from '../../lib/devicectl';
3+
import {describe, it, type TestContext} from 'node:test';
34

45
describe('manual sudo execution e2e', function () {
5-
it('runs devicectl as original non-root user under sudo', async function () {
6+
it('runs devicectl as original non-root user under sudo', async function (ctx: TestContext) {
67
if (
78
process.env.CI ||
89
process.platform !== 'darwin' ||
@@ -11,8 +12,7 @@ describe('manual sudo execution e2e', function () {
1112
!process.env.SUDO_UID ||
1213
!process.env.SUDO_GID
1314
) {
14-
this.skip();
15-
return;
15+
return ctx.skip();
1616
}
1717

1818
const devicectl = new Devicectl('');
@@ -21,7 +21,7 @@ describe('manual sudo execution e2e', function () {
2121
asJson: true,
2222
});
2323

24-
expect(result.stdout).to.be.a('string');
25-
expect(result.stdout.length).to.be.greaterThan(0);
24+
assert.strictEqual(typeof result.stdout, 'string');
25+
assert.ok(result.stdout.length > 0);
2626
});
2727
});
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {expect} from 'chai';
1+
import assert from 'node:assert/strict';
22
import {Devicectl} from '../../lib/devicectl';
33
import {appUrlToFilesystemPath, escapeProcessFilterValue} from '../../lib/mixins/process';
4+
import {describe, it, beforeEach} from 'node:test';
45

56
describe('Devicectl', function () {
67
let devicectl: Devicectl;
@@ -11,120 +12,124 @@ describe('Devicectl', function () {
1112

1213
describe('constructor', function () {
1314
it('should create a Devicectl instance with the provided UDID and default logger', function () {
14-
expect(devicectl.udid).to.equal('test-device-udid');
15+
assert.strictEqual(devicectl.udid, 'test-device-udid');
1516
});
1617

1718
it('should allow disabling non-root sudo execution in constructor options', function () {
1819
const localDevicectl = new Devicectl('test-device-udid', {preferNonRootWhenSudo: false});
19-
expect((localDevicectl as any).preferNonRootWhenSudo).to.equal(false);
20+
assert.strictEqual((localDevicectl as any).preferNonRootWhenSudo, false);
2021
});
2122
});
2223

2324
describe('sudo behavior', function () {
2425
it('should cache sudo user identity when available', function () {
2526
const localDevicectl = new Devicectl('test-device-udid');
26-
expect(
27+
assert.strictEqual(
2728
(localDevicectl as any).sudoUser === null || !!(localDevicectl as any).sudoUser,
28-
).to.equal(true);
29+
true,
30+
);
2931
});
3032

3133
it('should keep constructor default for runAsNonRootWhenSudo behavior', function () {
32-
expect((devicectl as any).preferNonRootWhenSudo).to.equal(true);
34+
assert.strictEqual((devicectl as any).preferNonRootWhenSudo, true);
3335
});
3436
});
3537

3638
describe('execute', function () {
3739
it('should throw an error when command execution fails', async function () {
3840
// This test would need to be mocked in a real implementation
3941
// For now, we'll just test that the method exists
40-
expect(devicectl.execute).to.be.a('function');
42+
assert.strictEqual(typeof devicectl.execute, 'function');
4143
});
4244
});
4345

4446
describe('sendMemoryWarning', function () {
4547
it('should be a function', function () {
46-
expect(devicectl.sendMemoryWarning).to.be.a('function');
48+
assert.strictEqual(typeof devicectl.sendMemoryWarning, 'function');
4749
});
4850
});
4951

5052
describe('listProcesses', function () {
5153
it('should be a function', function () {
52-
expect(devicectl.listProcesses).to.be.a('function');
54+
assert.strictEqual(typeof devicectl.listProcesses, 'function');
5355
});
5456
});
5557

5658
describe('listFiles', function () {
5759
it('should be a function', function () {
58-
expect(devicectl.listFiles).to.be.a('function');
60+
assert.strictEqual(typeof devicectl.listFiles, 'function');
5961
});
6062
});
6163

6264
describe('pullFile', function () {
6365
it('should be a function', function () {
64-
expect(devicectl.pullFile).to.be.a('function');
66+
assert.strictEqual(typeof devicectl.pullFile, 'function');
6567
});
6668
});
6769

6870
describe('sendSignalToProcess', function () {
6971
it('should be a function', function () {
70-
expect(devicectl.sendSignalToProcess).to.be.a('function');
72+
assert.strictEqual(typeof devicectl.sendSignalToProcess, 'function');
7173
});
7274
});
7375

7476
describe('listApps', function () {
7577
it('should be a function', function () {
76-
expect(devicectl.listApps).to.be.a('function');
78+
assert.strictEqual(typeof devicectl.listApps, 'function');
7779
});
7880
});
7981

8082
describe('launchApp', function () {
8183
it('should be a function', function () {
82-
expect(devicectl.launchApp).to.be.a('function');
84+
assert.strictEqual(typeof devicectl.launchApp, 'function');
8385
});
8486
});
8587

8688
describe('terminateApp', function () {
8789
it('should be a function', function () {
88-
expect(devicectl.terminateApp).to.be.a('function');
90+
assert.strictEqual(typeof devicectl.terminateApp, 'function');
8991
});
9092

9193
describe('appUrlToFilesystemPath', function () {
9294
it('should strip the file:// prefix', function () {
93-
expect(appUrlToFilesystemPath('file:///path/to/App.app')).to.equal('/path/to/App.app');
95+
assert.strictEqual(appUrlToFilesystemPath('file:///path/to/App.app'), '/path/to/App.app');
9496
});
9597

9698
it('should strip a trailing slash', function () {
97-
expect(appUrlToFilesystemPath('/path/to/App.app/')).to.equal('/path/to/App.app');
99+
assert.strictEqual(appUrlToFilesystemPath('/path/to/App.app/'), '/path/to/App.app');
98100
});
99101

100102
it('should strip both the file:// prefix and trailing slash', function () {
101-
expect(appUrlToFilesystemPath('file:///private/var/App.app/')).to.equal(
103+
assert.strictEqual(
104+
appUrlToFilesystemPath('file:///private/var/App.app/'),
102105
'/private/var/App.app',
103106
);
104107
});
105108

106109
it('should leave paths without a file:// prefix or trailing slash unchanged', function () {
107-
expect(appUrlToFilesystemPath('/path/to/App.app')).to.equal('/path/to/App.app');
110+
assert.strictEqual(appUrlToFilesystemPath('/path/to/App.app'), '/path/to/App.app');
108111
});
109112
});
110113

111114
describe('escapeProcessFilterValue', function () {
112115
it('should leave values without special characters unchanged', function () {
113-
expect(escapeProcessFilterValue('/path/to/App.app')).to.equal('/path/to/App.app');
116+
assert.strictEqual(escapeProcessFilterValue('/path/to/App.app'), '/path/to/App.app');
114117
});
115118

116119
it('should escape backslashes', function () {
117-
expect(escapeProcessFilterValue(String.raw`path\with\slashes`)).to.equal(
120+
assert.strictEqual(
121+
escapeProcessFilterValue(String.raw`path\with\slashes`),
118122
String.raw`path\\with\\slashes`,
119123
);
120124
});
121125

122126
it('should escape double quotes', function () {
123-
expect(escapeProcessFilterValue('path"with"quotes')).to.equal('path\\"with\\"quotes');
127+
assert.strictEqual(escapeProcessFilterValue('path"with"quotes'), 'path\\"with\\"quotes');
124128
});
125129

126130
it('should escape backslashes and double quotes together', function () {
127-
expect(escapeProcessFilterValue(String.raw`path\"mixed`)).to.equal(
131+
assert.strictEqual(
132+
escapeProcessFilterValue(String.raw`path\"mixed`),
128133
String.raw`path\\\"mixed`,
129134
);
130135
});
@@ -133,7 +138,7 @@ describe('Devicectl', function () {
133138

134139
describe('listDevices', function () {
135140
it('should be a function', function () {
136-
expect(devicectl.listDevices).to.be.a('function');
141+
assert.strictEqual(typeof devicectl.listDevices, 'function');
137142
});
138143
});
139144
});

tsconfig.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@
55
"outDir": "build",
66
"checkJs": true,
77
"esModuleInterop": true,
8-
"types": ["node", "mocha"],
8+
"types": ["node"],
99
"strict": true
1010
},
11-
"ts-node": {
12-
"transpileOnly": true,
13-
"compilerOptions": {
14-
"rootDir": "."
15-
}
16-
},
1711
"include": ["lib", "test"]
1812
}

0 commit comments

Comments
 (0)