fix: e2e-tests
re-add missing fake-plugin dev dep
export a `PROJECT_ROOT` from the `helpers` module; use this where needed (DRY)
MODIFY
package.json
package.json
"devDependencies": {
"@appium/eslint-config-appium": "file:./packages/eslint-config-appium",
"@babel/plugin-proposal-class-properties": "^7.13.0",
+ "@appium/fake-plugin": "^1.0.0",
"@babel/register": "^7.13.16",
"appium-test-support": "^1.3.3",
"asyncbox": "^2.8.0",

MODIFY
packages/appium/test/cli-e2e-specs.js
packages/appium/test/cli-e2e-specs.js
@@ -4,15 +4,11 @@ import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { tempDir, fs, mkdirp, util } from 'appium-support';
import { KNOWN_DRIVERS } from '../lib/drivers';
-import findUp from 'find-up';
+import { PROJECT_ROOT as cwd } from './helpers';
chai.should();
chai.use(chaiAsPromised);
-// monorepo root. this cannot be hardcoded because:
-// 1. we may be in 'build/test' or 'test', depending on our config
-// 2. Node.js does not support `__dirname` in an ESM context & Babel doesn't fake it well
-const cwd = path.dirname(findUp.sync('.git', {type: 'directory'}));
// cannot use `require.resolve()` here (w/o acrobatics) due to the ESM context.
// could also derive it from the `package.json` if we wanted
const executable = path.join(cwd, 'packages', 'appium', 'build', 'lib', 'main.js');

MODIFY
packages/appium/test/helpers.js
packages/appium/test/helpers.js
import path from 'path';
import {insertAppiumPrefixes} from '../lib/utils';
+import findUp from 'find-up';
const TEST_HOST = 'localhost';
const TEST_PORT = 4723;
-const TEST_FAKE_APP = path.resolve(__dirname, '..', '..', '..', 'fake-driver', 'test', 'fixtures',
- 'app.xml');
+
+// monorepo root. this cannot be hardcoded because:
+// 1. we may be in 'build/test' or 'test', depending on our config
+// 2. Node.js does not support `__dirname` in an ESM context & Babel doesn't fake it well
+const PROJECT_ROOT = path.dirname(findUp.sync('.git', {type: 'directory'}));
+const TEST_FAKE_APP = path.join(PROJECT_ROOT, 'packages', 'fake-driver', 'test', 'fixtures', 'app.xml');
const BASE_CAPS = {
automationName: 'Fake',
@@ -18,4 +23,4 @@ const W3C_CAPS = {
firstMatch: [{}],
};
-export { TEST_FAKE_APP, TEST_HOST, TEST_PORT, BASE_CAPS, W3C_PREFIXED_CAPS, W3C_CAPS };
+export { TEST_FAKE_APP, TEST_HOST, TEST_PORT, BASE_CAPS, W3C_PREFIXED_CAPS, W3C_CAPS, PROJECT_ROOT };

MODIFY
packages/appium/test/plugin-e2e-specs.js
packages/appium/test/plugin-e2e-specs.js
@@ -8,16 +8,15 @@ import { remote as wdio } from 'webdriverio';
import axios from 'axios';
import { main as appiumServer } from '../lib/main';
import { DEFAULT_APPIUM_HOME, INSTALL_TYPE_LOCAL, DRIVER_TYPE, PLUGIN_TYPE } from '../lib/extension-config';
-import { W3C_PREFIXED_CAPS, TEST_HOST, TEST_PORT } from './helpers';
+import { W3C_PREFIXED_CAPS, TEST_HOST, TEST_PORT, PROJECT_ROOT } from './helpers';
import { runExtensionCommand } from '../lib/cli/extension';
-import findUp from 'find-up';
chai.should();
chai.use(chaiAsPromised);
-const root = path.dirname(findUp.sync('.git', {type: 'directory'}));
+
// TODO: update when fake-plugin pulled in to monorepo
-const FAKE_PLUGIN_DIR = path.join(root, 'node_modules', '@appium', 'fake-plugin');
-const FAKE_DRIVER_DIR = path.join(root, 'packages', 'fake-driver');
+const FAKE_PLUGIN_DIR = path.join(PROJECT_ROOT, 'node_modules', '@appium', 'fake-plugin');
+const FAKE_DRIVER_DIR = path.join(PROJECT_ROOT, 'packages', 'fake-driver');
const TEST_SERVER = `http://${TEST_HOST}:${TEST_PORT}`;
const wdOpts = {

fix: e2e-tests

- re-add missing fake-plugin dev dep
- export a `PROJECT_ROOT` from the `helpers` module; use this where needed (DRY)