UNPKG

appium-webdriveragent

Version:
133 lines 5.62 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = __importStar(require("chai")); const chai_as_promised_1 = __importDefault(require("chai-as-promised")); const node_simctl_1 = require("node-simctl"); const appium_ios_simulator_1 = require("appium-ios-simulator"); const simulator_1 = require("./helpers/simulator"); const teen_process_1 = require("teen_process"); const desired_1 = require("./desired"); const asyncbox_1 = require("asyncbox"); const webdriveragent_1 = require("../../lib/webdriveragent"); const axios_1 = __importDefault(require("axios")); chai_1.default.use(chai_as_promised_1.default); const MOCHA_TIMEOUT_MS = 60 * 1000 * 5; const SIM_DEVICE_NAME = 'webDriverAgentTest'; const SIM_STARTUP_TIMEOUT_MS = MOCHA_TIMEOUT_MS; const testUrl = 'http://localhost:8100/tree'; function getStartOpts(device) { return { device, platformVersion: desired_1.PLATFORM_VERSION, host: 'localhost', port: 8100, realDevice: false, showXcodeLog: true, wdaLaunchTimeout: 60 * 3 * 1000, }; } describe('WebDriverAgent', function () { this.timeout(MOCHA_TIMEOUT_MS); describe('with fresh sim', function () { let device; let simctl; before(async function () { simctl = new node_simctl_1.Simctl(); simctl.udid = await simctl.createDevice(SIM_DEVICE_NAME, desired_1.DEVICE_NAME, desired_1.PLATFORM_VERSION); device = await (0, appium_ios_simulator_1.getSimulator)(simctl.udid); // Prebuild WDA const wda = new webdriveragent_1.WebDriverAgent({ iosSdkVersion: desired_1.PLATFORM_VERSION, platformVersion: desired_1.PLATFORM_VERSION, showXcodeLog: true, device, }); if (wda.xcodebuild) { await wda.xcodebuild.start(true); } }); after(async function () { this.timeout(MOCHA_TIMEOUT_MS); await (0, simulator_1.shutdownSimulator)(device); await simctl.deleteDevice(); }); describe('with running sim', function () { this.timeout(6 * 60 * 1000); beforeEach(async function () { await (0, simulator_1.killAllSimulators)(); await device.run({ startupTimeout: SIM_STARTUP_TIMEOUT_MS }); }); afterEach(async function () { try { await (0, asyncbox_1.retryInterval)(5, 1000, async function () { await (0, simulator_1.shutdownSimulator)(device); }); } catch { } }); it('should launch agent on a sim', async function () { const agent = new webdriveragent_1.WebDriverAgent(getStartOpts(device)); await agent.launch('sessionId'); await (0, chai_1.expect)((0, axios_1.default)({ url: testUrl })).to.be.rejected; await agent.quit(); }); it('should fail if xcodebuild fails', async function () { // short timeout this.timeout(35 * 1000); const agent = new webdriveragent_1.WebDriverAgent(getStartOpts(device)); agent.xcodebuild.createSubProcess = async function () { const args = [ '-workspace', `${this.agentPath}dfgs`, // '-scheme', // 'XCTUITestRunner', // '-destination', // `id=${this.device.udid}`, // 'test' ]; return new teen_process_1.SubProcess('xcodebuild', args, { detached: true }); }; await (0, chai_1.expect)(agent.launch('sessionId')) .to.be.rejectedWith('xcodebuild failed'); await agent.quit(); }); }); }); }); //# sourceMappingURL=webdriveragent-e2e-specs.js.map