appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
70 lines • 3.2 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mobileRunXCTest = mobileRunXCTest;
exports.mobileInstallXCTestBundle = mobileInstallXCTestBundle;
exports.mobileListXCTestBundles = mobileListXCTestBundles;
const support_1 = require("appium/support");
const lodash_1 = __importDefault(require("lodash"));
const driver_1 = require("appium/driver");
const xctest_client_1 = require("../device/xctest-client");
const XCTEST_TIMEOUT = 360000; // 6 minute timeout
const xctestLog = support_1.logger.getLogger('XCTest');
/**
* Run a native XCTest script.
*
* Supported only on **real devices** running **iOS/tvOS 18+** with the optional **appium-ios-remotexpc**
* package installed. UI and app test types use RemoteXPC. Logic tests are not supported. This API does
* not run XCTest bundles on simulators.
*
* @param testRunnerBundleId - Test app bundle (e.g.: `io.appium.XCTesterAppUITests.xctrunner`)
* @param appUnderTestBundleId - App-under-test bundle
* @param xcTestBundleId - XCTest bundle ID
* @param args - Launch arguments to start the test with (see [reference documentation](https://developer.apple.com/documentation/xctest/xcuiapplication/1500477-launcharguments))
* @param testType - XC test type
* @param env - Environment variables passed to test
* @param timeout - Timeout (in ms) for session completion
* @returns The array of test results
* @throws {Error} Error thrown if XCTest execution fails
*/
async function mobileRunXCTest(testRunnerBundleId, appUnderTestBundleId, xcTestBundleId, args = [], testType = 'ui', env, timeout = XCTEST_TIMEOUT) {
return await xctest_client_1.XCTestClient.fromDriver(this).run({
testRunnerBundleId,
appUnderTestBundleId,
xcTestBundleId,
args,
testType,
env,
timeout,
});
}
/**
* Installs an XCTest bundle to the device under test.
*
* Supported only on real devices running iOS/tvOS 18+ with appium-ios-remotexpc. Use a `.app` or `.ipa`;
* bare `.xctest` bundles are not supported via RemoteXPC.
*
* @param xctestApp - Path of the XCTest app (URL or filename with extension `.app`)
*/
async function mobileInstallXCTestBundle(xctestApp) {
if (!lodash_1.default.isString(xctestApp)) {
throw new driver_1.errors.InvalidArgumentError(`'xctestApp' is a required parameter for 'installXCTestBundle' and ` +
`must be a string. Found '${xctestApp}'`);
}
xctestLog.info(`Installing bundle '${xctestApp}'`);
const res = await this.helpers.configureApp(xctestApp, '.xctest');
await xctest_client_1.XCTestClient.fromDriver(this).installBundle(res);
}
/**
* List XCTest bundles that are installed on the device.
*
* Supported only on real devices running iOS/tvOS 18+ with appium-ios-remotexpc.
*
* @returns List of XCTest bundles (e.g.: `XCTesterAppUITests.XCTesterAppUITests/testLaunchPerformance`)
*/
async function mobileListXCTestBundles() {
return await xctest_client_1.XCTestClient.fromDriver(this).listBundles();
}
//# sourceMappingURL=xctest.js.map