UNPKG

cybernaut

Version:

Reliable, automated web UI testing in BDD-style.

35 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const utils_1 = require("./utils"); function createExecutor(action) { const { description } = action; return (driver, attempt, retries) => tslib_1.__awaiter(this, void 0, void 0, function* () { try { yield action.perform(driver); const attempts = ` (attempt ${attempt} of ${retries + 1})`; return { description: action.description + (attempt > 1 ? attempts : ''), error: false }; } catch (e) { const error = e && e.message ? e.message : 'unknown error'; return { description: `${description} (${error})`, error: true }; } }); } exports.createExecutor = createExecutor; function execute(executor, driver, options, _attempt = 1) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { retries, retryDelay } = options; const execution = yield executor(driver, _attempt, retries); if (!execution.error || retries < _attempt) { return execution; } yield utils_1.sleep(retryDelay); return execute(executor, driver, options, _attempt + 1); }); } exports.execute = execute; //# sourceMappingURL=execution.js.map