diff --git a/package.json b/package.json index 8497c29..0095b9e 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "lint": "eslint .", "lint:fix": "npm run lint -- --fix", "prepare": "npm run build", - "test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.js\"", + "test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.*js\"", "e2e-test": "mocha --exit --timeout 5m \"./test/e2e/**/*-specs.js\"" }, "prettier": { diff --git a/test/unit/simctl-specs.js b/test/unit/simctl-specs.cjs similarity index 94% rename from test/unit/simctl-specs.js rename to test/unit/simctl-specs.cjs index 19e589b..fdf02d5 100644 --- a/test/unit/simctl-specs.js +++ b/test/unit/simctl-specs.cjs @@ -3,37 +3,24 @@ import sinon from 'sinon'; import * as TeenProcess from 'teen_process'; import _ from 'lodash'; import fs from 'node:fs'; -import path from 'node:path'; -import { fileURLToPath } from 'url'; const proxyquire = pq.noCallThru(); -const FILENAME = getFilename(); -const DIRNAME = path.dirname(FILENAME); - -function getFilename() { - try { - const url = eval('import.meta.url'); - return fileURLToPath(url); - } catch (e) { - return __filename; - } -} const devicePayloads = [ [ { - stdout: fs.readFileSync(`${DIRNAME}/fixtures/devices.json`, 'utf-8'), + stdout: fs.readFileSync(`${__dirname}/fixtures/devices.json`, 'utf-8'), }, { - stdout: fs.readFileSync(`${DIRNAME}/fixtures/devices-with-unavailable.json`, 'utf-8'), + stdout: fs.readFileSync(`${__dirname}/fixtures/devices-with-unavailable.json`, 'utf-8'), }, ], [ { - stdout: fs.readFileSync(`${DIRNAME}/fixtures/devices-simple.json`, 'utf-8'), + stdout: fs.readFileSync(`${__dirname}/fixtures/devices-simple.json`, 'utf-8'), }, { - stdout: fs.readFileSync(`${DIRNAME}/fixtures/devices-with-unavailable-simple.json`, 'utf-8'), + stdout: fs.readFileSync(`${__dirname}/fixtures/devices-with-unavailable-simple.json`, 'utf-8'), }, ], ]; @@ -60,6 +47,7 @@ describe('simctl', function () { chai.use(chaiAsPromised.default); }); + describe('getDevices', function () { let simctl; diff --git a/tsconfig.json b/tsconfig.json index 33d83ef..8de7b04 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,8 @@ "$schema": "https://json.schemastore.org/tsconfig", "extends": "@appium/tsconfig/tsconfig.json", "compilerOptions": { - "strict": false, // TODO: make this flag true + "strict": false, + "esModuleInterop": true, "outDir": "build", "types": ["node"], "checkJs": true