Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .mocharc.js

This file was deleted.

11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"format": "prettier -w ./lib ./test",
"format:check": "prettier --check ./lib ./test",
"prepare": "npm run build",
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.ts\"",
"e2e-test": "mocha --exit --timeout 5m \"./test/e2e/**/*-specs.ts\""
"test": "node --test --test-timeout=60000 \"./build/test/unit/**/*.spec.js\"",
"e2e-test": "node --test --test-force-exit --test-concurrency=1 --test-timeout=300000 \"./build/test/e2e/**/*.spec.js\""
},
"prettier": {
"bracketSpacing": false,
Expand All @@ -57,18 +57,11 @@
"@appium/types": "^1.0.0-rc.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@types/chai": "^5.2.3",
"@types/chai-as-promised": "^8.0.2",
"@types/mocha": "^10.0.1",
"@types/node": "^26.0.0",
"@types/semver": "^7.7.1",
"chai": "^6.0.0",
"chai-as-promised": "^8.0.0",
"conventional-changelog-conventionalcommits": "^9.3.1",
"mocha": "^11.0.1",
"prettier": "^3.9.3",
"semantic-release": "^25.0.2",
"ts-node": "^10.9.1",
"typescript": "^6.0.2"
}
}
64 changes: 30 additions & 34 deletions test/e2e/xcode-specs.ts → test/e2e/xcode.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import {fs, util} from '@appium/support';
import {expect, use} from 'chai';
import chaiAsPromised from 'chai-as-promised';
import assert from 'node:assert/strict';
import * as xcode from '../../lib/xcode';
import {describe, it} from 'node:test';

use(chaiAsPromised);

describe('xcode @skip-linux', function () {
// on slow machines and busy CI systems these can be slow and flakey
this.timeout(30000);

// on slow machines and busy CI systems these can be slow and flakey
describe('xcode', {timeout: 30000}, function () {
describe('getPath', function () {
it('should get the path to xcode from xcode-select', async function () {
const xcodePath = await xcode.getPathFromXcodeSelect();
expect(xcodePath).to.exist;
assert.ok(xcodePath);
await fs.exists(xcodePath);
});

it('should get the path to xcode if provided in DEVELOPER_DIR', async function () {
process.env.DEVELOPER_DIR = await xcode.getPathFromXcodeSelect();
try {
const xcodePath = await xcode.getPathFromDeveloperDir();
expect(xcodePath).to.exist;
assert.ok(xcodePath);
await fs.exists(xcodePath);
} finally {
delete process.env.DEVELOPER_DIR;
Expand All @@ -30,15 +26,15 @@ describe('xcode @skip-linux', function () {
it('should fail if the path to xcode provided in DEVELOPER_DIR is wrong', async function () {
process.env.DEVELOPER_DIR = 'yolo';
try {
await expect(xcode.getPathFromDeveloperDir()).to.be.rejected;
await assert.rejects(() => xcode.getPathFromDeveloperDir());
} finally {
delete process.env.DEVELOPER_DIR;
}
});

it('should get the path to xcode', async function () {
const xcodePath = await xcode.getPath();
expect(xcodePath).to.eql(await xcode.getPathFromXcodeSelect());
assert.strictEqual(xcodePath, await xcode.getPathFromXcodeSelect());
});
});

Expand All @@ -47,9 +43,9 @@ describe('xcode @skip-linux', function () {

it('should get the version of xcode', async function () {
const version = await xcode.getVersion(false);
expect(version).to.exist;
expect(version).to.be.a('string');
expect(versionRE.test(version)).to.be.true;
assert.ok(version);
assert.strictEqual(typeof version, 'string');
assert.ok(versionRE.test(version));
});

it('should get the path and version again, these values are cached', async function () {
Expand All @@ -60,51 +56,51 @@ describe('xcode @skip-linux', function () {
const xcodePath = await xcode.getPath();
let after = Number(new Date());

expect(xcodePath).to.exist;
assert.ok(xcodePath);
await fs.exists(xcodePath);
expect(after - before).to.be.at.most(2);
assert.ok(after - before <= 2);

before = Number(new Date());
const version = await xcode.getVersion(false);
after = Number(new Date());

expect(version).to.exist;
expect(version).to.be.a('string');
expect(versionRE.test(version)).to.be.true;
expect(after - before).to.be.at.most(2);
assert.ok(version);
assert.strictEqual(typeof version, 'string');
assert.ok(versionRE.test(version));
assert.ok(after - before <= 2);
});

it('should get the parsed version', async function () {
const nonParsedVersion = await xcode.getVersion(false);
const version = await xcode.getVersion(true);
expect(version).to.exist;
expect(version.versionString).to.be.a('string');
expect(version.versionString).to.eql(nonParsedVersion);
assert.ok(version);
assert.strictEqual(typeof version.versionString, 'string');
assert.strictEqual(version.versionString, nonParsedVersion);

expect(parseFloat(String(version.versionFloat))).to.equal(version.versionFloat);
expect(parseInt(String(version.major), 10)).to.equal(version.major);
expect(parseInt(String(version.minor), 10)).to.equal(version.minor);
assert.strictEqual(parseFloat(String(version.versionFloat)), version.versionFloat);
assert.strictEqual(parseInt(String(version.major), 10), version.major);
assert.strictEqual(parseInt(String(version.minor), 10), version.minor);
});
});

it('should get clang version', async function () {
const cliVersion = await xcode.getClangVersion();
expect(cliVersion).to.exist;
expect(util.coerceVersion(cliVersion!, true)).to.be.a('string');
assert.ok(cliVersion);
assert.strictEqual(typeof util.coerceVersion(cliVersion!, true), 'string');
});

it('should get max iOS SDK version', async function () {
const version = await xcode.getMaxIOSSDK();

expect(version).to.exist;
expect(version).to.be.a('string');
expect(parseFloat(String(version)) - 6.1).to.be.at.least(0);
assert.ok(version);
assert.strictEqual(typeof version, 'string');
assert.ok(parseFloat(String(version)) - 6.1 >= 0);
});

it('should get max tvOS SDK version', async function () {
const version = await xcode.getMaxTVOSSDK();

expect(version).to.exist;
expect(version).to.be.a('string');
assert.ok(version);
assert.strictEqual(typeof version, 'string');
});
});
5 changes: 3 additions & 2 deletions test/unit/index-specs.ts → test/unit/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {expect} from 'chai';
import assert from 'node:assert/strict';
import xcode from '../../lib/index';
import {describe, it} from 'node:test';

describe('index', function () {
it('exported objects should exist', function () {
expect(xcode).to.exist;
assert.ok(xcode);
});
});
8 changes: 1 addition & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
"extends": "@appium/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "build",
"types": ["node", "mocha"],
"types": ["node"],
"checkJs": true,
"strict": true
},
"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"rootDir": "."
}
},
"include": [
"lib",
"test"
Expand Down
Loading