diff --git a/.mocharc.js b/.mocharc.js deleted file mode 100644 index 40599e9..0000000 --- a/.mocharc.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - require: ['ts-node/register'], - forbidOnly: Boolean(process.env.CI) -}; diff --git a/package.json b/package.json index 71ac835..30ea100 100644 --- a/package.json +++ b/package.json @@ -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, @@ -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" } } diff --git a/test/e2e/xcode-specs.ts b/test/e2e/xcode.spec.ts similarity index 59% rename from test/e2e/xcode-specs.ts rename to test/e2e/xcode.spec.ts index 12159e5..e11930d 100644 --- a/test/e2e/xcode-specs.ts +++ b/test/e2e/xcode.spec.ts @@ -1,18 +1,14 @@ 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); }); @@ -20,7 +16,7 @@ describe('xcode @skip-linux', 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; @@ -30,7 +26,7 @@ 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; } @@ -38,7 +34,7 @@ describe('xcode @skip-linux', function () { 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()); }); }); @@ -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 () { @@ -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'); }); }); diff --git a/test/unit/index-specs.ts b/test/unit/index.spec.ts similarity index 56% rename from test/unit/index-specs.ts rename to test/unit/index.spec.ts index fa89766..4766378 100644 --- a/test/unit/index-specs.ts +++ b/test/unit/index.spec.ts @@ -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); }); }); diff --git a/tsconfig.json b/tsconfig.json index d7817ee..906ef91 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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"