UNPKG

cybernaut

Version:

Reliable, automated web UI testing in BDD-style.

48 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const execution_1 = require("./execution"); const verification_1 = require("./verification"); class TestContext { constructor(driver, logger, options) { this._driver = driver; this._logger = logger; this._options = options; } assert(accessor, predicate, options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const verifier = verification_1.createVerifier(accessor, predicate); const verification = yield verification_1.verify(verifier, this._driver, Object.assign({}, this._options, options)); const message = 'Assert: ' + verification.description; if (verification.result === 'error' || verification.result === 'invalid') { throw new Error(message); } this._logger.pass(message); }); } perform(action, options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const executor = execution_1.createExecutor(action); const execution = yield execution_1.execute(executor, this._driver, Object.assign({}, this._options, options)); const message = 'Perform: ' + execution.description; if (execution.error) { throw new Error(message); } this._logger.pass(message); }); } verify(accessor, predicate, options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const verifier = verification_1.createVerifier(accessor, predicate); const verification = yield verification_1.verify(verifier, this._driver, Object.assign({}, this._options, options)); const message = 'Verify: ' + verification.description; if (verification.result === 'error') { throw new Error(message); } this._logger.pass(message); return verification.result === 'valid'; }); } } exports.TestContext = TestContext; //# sourceMappingURL=test-context.js.map