diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index cc5df7f..7d20479 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -5,11 +5,11 @@ jobs: prepare_matrix: runs-on: ubuntu-latest outputs: - versions: ${{ steps.generate-matrix.outputs.versions }} + versions: ${{ steps.generate-matrix.outputs.active }} steps: - - name: Select 3 most recent LTS versions of Node.js + - name: Select all active LTS versions of Node.js id: generate-matrix - run: echo "versions=$(curl -s https://endoflife.date/api/nodejs.json | jq -c '[[.[] | select(.lts != false)][:3] | .[].cycle | tonumber]')" >> "$GITHUB_OUTPUT" + uses: msimerson/node-lts-versions@v1 test: runs-on: ubuntu-latest diff --git a/package.json b/package.json index 59475b8..e6512b4 100644 --- a/package.json +++ b/package.json @@ -64,16 +64,12 @@ "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", "@types/bluebird": "^3.5.38", - "@types/chai": "^4.3.5", - "@types/chai-as-promised": "^7.1.5", "@types/lodash": "^4.14.196", "@types/mocha": "^10.0.1", "@types/node": "^20.4.7", - "@types/sinon": "^17.0.0", - "@types/sinon-chai": "^3.2.9", "@types/teen_process": "^2.0.1", - "chai": "^4.1.2", - "chai-as-promised": "^7.1.1", + "chai": "^5.1.1", + "chai-as-promised": "^8.0.0", "conventional-changelog-conventionalcommits": "^8.0.0", "mocha": "^10.0.0", "prettier": "^3.0.0", diff --git a/test/afc/afc-specs.js b/test/afc/afc-specs.js index 17dfd30..22b8931 100644 --- a/test/afc/afc-specs.js +++ b/test/afc/afc-specs.js @@ -1,14 +1,16 @@ -import chai from 'chai'; import AfcService from '../../lib/afc'; import { getServerWithFixtures, fixtures } from '../fixtures'; - -chai.should(); - describe('afc', function () { let server; let socket; let service; + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); afterEach(function () { service.close(); diff --git a/test/imagemounter/list-developer-image-specs.js b/test/imagemounter/list-developer-image-specs.js index 315e10f..af8ddd0 100644 --- a/test/imagemounter/list-developer-image-specs.js +++ b/test/imagemounter/list-developer-image-specs.js @@ -1,26 +1,33 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; import { findDeveloperImage } from '../../lib/imagemounter/utils/list_developer_image'; import { fs } from '@appium/support'; -chai.should(); -chai.use(chaiAsPromised); + + describe('findDeveloperImage', function () { - it('should download and return the correct developer image for a given version', async function () { - const result = await findDeveloperImage('14.7.1', { - githubRepo: 'appium/appium-ios-device', - subFolderList: ['test', 'imagemounter'], - branch: 'master' - }); - result.developerImage.endsWith('/DeveloperDiskImage.dmg').should.be.true; - result.developerImageSignature.endsWith('/DeveloperDiskImage.dmg.signature').should.be.true; - (await fs.exists(result.developerImage)).should.be.true; - (await fs.exists(result.developerImageSignature)).should.be.true; - }); + let chai; - it('should throw an error if the developer image cannot be found', function () { - findDeveloperImage('99.99.99', { - githubRepo: 'appium/appium-ios-device', - subFolderList: ['test', 'imagemounter'] - }).should.be.rejectedWith('Failed to get developer image for iOS 99.99'); + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + chai.should(); + chai.use(chaiAsPromised.default); + }); + + it('should download and return the correct developer image for a given version', async function () { + const result = await findDeveloperImage('14.7.1', { + githubRepo: 'appium/appium-ios-device', + subFolderList: ['test', 'imagemounter'], + branch: 'master' }); + result.developerImage.endsWith('/DeveloperDiskImage.dmg').should.be.true; + result.developerImageSignature.endsWith('/DeveloperDiskImage.dmg.signature').should.be.true; + (await fs.exists(result.developerImage)).should.be.true; + (await fs.exists(result.developerImageSignature)).should.be.true; + }); + + it('should throw an error if the developer image cannot be found', function () { + findDeveloperImage('99.99.99', { + githubRepo: 'appium/appium-ios-device', + subFolderList: ['test', 'imagemounter'] + }).should.be.rejectedWith('Failed to get developer image for iOS 99.99'); + }); }); \ No newline at end of file diff --git a/test/installation-proxy/installation-proxy-service-specs.js b/test/installation-proxy/installation-proxy-service-specs.js index a965455..c184102 100644 --- a/test/installation-proxy/installation-proxy-service-specs.js +++ b/test/installation-proxy/installation-proxy-service-specs.js @@ -1,15 +1,17 @@ -import chai from 'chai'; import InstallationServiceProxy from '../../lib/installation-proxy'; import PlistService from '../../lib/plist-service'; import { getServerWithFixtures, fixtures } from '../fixtures'; - -chai.should(); - describe('installation proxy', function () { let server; let socket; let installationServiceProxy; + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); afterEach(function () { if (installationServiceProxy) { diff --git a/test/instrument/instrument-service-specs.js b/test/instrument/instrument-service-specs.js index 55da25c..ff18e2f 100644 --- a/test/instrument/instrument-service-specs.js +++ b/test/instrument/instrument-service-specs.js @@ -1,16 +1,18 @@ -import chai from 'chai'; import {InstrumentService, INSTRUMENT_CHANNEL} from '../../lib/instrument'; import { getServerWithFixtures, fixtures } from '../fixtures'; import B from 'bluebird'; - -chai.should(); - describe('instrument', function () { let server; let socket; let instrumentService; const pid = 6385; + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); afterEach(function () { if (instrumentService) { diff --git a/test/instrument/nskeyed-specs.js b/test/instrument/nskeyed-specs.js index d78d30a..30c8bc0 100644 --- a/test/instrument/nskeyed-specs.js +++ b/test/instrument/nskeyed-specs.js @@ -1,11 +1,13 @@ -import chai from 'chai'; import {unarchive, archive, NSURL, NSUUID, NSDate} from '../../lib/instrument/transformer/nskeyed'; import {v4} from 'uuid'; - -chai.should(); - describe('NSKeyedArchive', function () { + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); it('should parses JavaScript objects into iOS NSKeyedArchive data', function () { const data = { diff --git a/test/lockdown/lockdown-specs.js b/test/lockdown/lockdown-specs.js index c390131..44892a1 100644 --- a/test/lockdown/lockdown-specs.js +++ b/test/lockdown/lockdown-specs.js @@ -1,16 +1,18 @@ import { Lockdown } from '../../lib/lockdown'; import { PlistService } from '../../lib/plist-service'; import { getServerWithFixtures, fixtures } from '../fixtures'; -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; - - -chai.should(); -chai.use(chaiAsPromised); describe('lockdown', function () { let server; let socket; + let chai; + + before(async function () { + chai = await import('chai'); + const chaiAsPromised = await import('chai-as-promised'); + chai.should(); + chai.use(chaiAsPromised.default); + }); afterEach(function () { try { diff --git a/test/syslog/syslog-service-specs.js b/test/syslog/syslog-service-specs.js index 53a213a..e23608e 100644 --- a/test/syslog/syslog-service-specs.js +++ b/test/syslog/syslog-service-specs.js @@ -1,16 +1,18 @@ import B from 'bluebird'; -import chai from 'chai'; import SyslogService from '../../lib/syslog'; import { getServerWithFixtures, fixtures } from '../fixtures'; import { toUtf8String } from '../../lib/syslog/transformer/syslog-decoder'; - -chai.should(); - describe('syslog', function () { let server; let socket; let syslogService; + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); afterEach(function () { syslogService?.close(); diff --git a/test/usbmux/usbmux-specs.js b/test/usbmux/usbmux-specs.js index e9c28ff..e412a38 100644 --- a/test/usbmux/usbmux-specs.js +++ b/test/usbmux/usbmux-specs.js @@ -1,14 +1,16 @@ import { Usbmux } from '../..'; -import chai from 'chai'; import { getServerWithFixtures, fixtures, UDID } from '../fixtures'; - -chai.should(); - describe('usbmux', function () { let usbmux; let server; let socket; + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); afterEach(function () { try { diff --git a/test/utilities-specs.js b/test/utilities-specs.js index fcaafeb..907a6e0 100644 --- a/test/utilities-specs.js +++ b/test/utilities-specs.js @@ -1,13 +1,16 @@ import { utilities } from '..'; -import chai from 'chai'; import { getServerWithFixtures, fixtures, UDID } from './fixtures'; -chai.should(); - describe('utilities', function () { let server; let socket; + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); afterEach(function () { if (server) { diff --git a/test/webinspector/webinspector-helpers-specs.js b/test/webinspector/webinspector-helpers-specs.js index eafce1a..db32191 100644 --- a/test/webinspector/webinspector-helpers-specs.js +++ b/test/webinspector/webinspector-helpers-specs.js @@ -1,10 +1,12 @@ -import chai from 'chai'; import { cleanupRpcObject } from '../../lib/webinspector'; - -chai.should(); - describe('webinspector helpers', function () { + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); it('should cleanup an rpc object', function () { cleanupRpcObject({ diff --git a/test/webinspector/webinspector-service-specs.js b/test/webinspector/webinspector-service-specs.js index 25993fa..f5e13cd 100644 --- a/test/webinspector/webinspector-service-specs.js +++ b/test/webinspector/webinspector-service-specs.js @@ -1,16 +1,18 @@ -import chai from 'chai'; import B from 'bluebird'; import semver from 'semver'; import WebInspectorService from '../../lib/webinspector'; import { getServerWithFixtures, fixtures } from '../fixtures'; - -chai.should(); - describe('webinspector', function () { let server; let socket; let webInspectorService; + let chai; + + before(async function () { + chai = await import('chai'); + chai.should(); + }); afterEach(function () { if (webInspectorService) {