UNPKG

allure-js-commons

Version:
204 lines (202 loc) 5.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.noopSyncRuntime = exports.noopRuntime = exports.SYNC_STEP_PURE_FUNCTION_ERROR = exports.NoopTestRuntime = exports.NoopSyncTestRuntime = exports.NOOP_SYNC_RUNTIME_WARNING = exports.NOOP_RUNTIME_WARNING = void 0; var _utils = require("../utils.js"); function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var NOOP_RUNTIME_WARNING = exports.NOOP_RUNTIME_WARNING = "no test runtime is found. Please check test framework configuration"; var NOOP_SYNC_RUNTIME_WARNING = exports.NOOP_SYNC_RUNTIME_WARNING = "no sync test runtime is found. Please check test framework configuration and adapter sync support"; var SYNC_STEP_PURE_FUNCTION_ERROR = exports.SYNC_STEP_PURE_FUNCTION_ERROR = "allure-js-commons/sync step body must be synchronous and must not return a Promise"; class NoopSyncTestRuntime { attachment(_, __, ___) { this.warning(); } attachmentFromPath(_, __, ___) { this.warning(); } globalAttachment(_, __, ___) { this.warning(); } globalAttachmentFromPath(_, __, ___) { this.warning(); } globalError(_) { this.warning(); } description(_) { this.warning(); } descriptionHtml(_) { this.warning(); } displayName(_) { this.warning(); } historyId(_) { this.warning(); } labels() { this.warning(); } links() { this.warning(); } parameter(_, __, ___) { this.warning(); } logStep(_, __, ___) { this.warning(); } step(_, body) { this.warning(); var result = body(); if ((0, _utils.isPromise)(result)) { var error = new Error(SYNC_STEP_PURE_FUNCTION_ERROR); this.warnAboutPromiseStep(); throw error; } return result; } stepDisplayName(_) { this.warning(); } stepParameter(_, __, ___) { this.warning(); } testCaseId(_) { this.warning(); } warning() { // eslint-disable-next-line no-console console.warn(NOOP_SYNC_RUNTIME_WARNING); } warnAboutPromiseStep() { // eslint-disable-next-line no-console console.warn(SYNC_STEP_PURE_FUNCTION_ERROR); } } exports.NoopSyncTestRuntime = NoopSyncTestRuntime; var noopSyncRuntime = exports.noopSyncRuntime = new NoopSyncTestRuntime(); class NoopTestRuntime { constructor() { _defineProperty(this, "sync", noopSyncRuntime); } attachment() { var _this = this; return _asyncToGenerator(function* () { yield _this.warning(); })(); } attachmentFromPath() { var _this2 = this; return _asyncToGenerator(function* () { yield _this2.warning(); })(); } globalAttachment() { var _this3 = this; return _asyncToGenerator(function* () { yield _this3.warning(); })(); } globalAttachmentFromPath() { var _this4 = this; return _asyncToGenerator(function* () { yield _this4.warning(); })(); } globalError() { var _this5 = this; return _asyncToGenerator(function* () { yield _this5.warning(); })(); } description() { var _this6 = this; return _asyncToGenerator(function* () { yield _this6.warning(); })(); } descriptionHtml() { var _this7 = this; return _asyncToGenerator(function* () { yield _this7.warning(); })(); } displayName() { var _this8 = this; return _asyncToGenerator(function* () { yield _this8.warning(); })(); } historyId() { var _this9 = this; return _asyncToGenerator(function* () { yield _this9.warning(); })(); } labels() { var _this0 = this; return _asyncToGenerator(function* () { yield _this0.warning(); })(); } links() { var _this1 = this; return _asyncToGenerator(function* () { yield _this1.warning(); })(); } parameter() { var _this10 = this; return _asyncToGenerator(function* () { yield _this10.warning(); })(); } logStep() { var _this11 = this; return _asyncToGenerator(function* () { yield _this11.warning(); })(); } step(_, body) { var _this12 = this; return _asyncToGenerator(function* () { yield _this12.warning(); return body(); })(); } stepDisplayName() { var _this13 = this; return _asyncToGenerator(function* () { yield _this13.warning(); })(); } stepParameter() { var _this14 = this; return _asyncToGenerator(function* () { yield _this14.warning(); })(); } testCaseId() { var _this15 = this; return _asyncToGenerator(function* () { yield _this15.warning(); })(); } // eslint-disable-next-line @typescript-eslint/require-await warning() { return _asyncToGenerator(function* () { // eslint-disable-next-line no-console console.log(NOOP_RUNTIME_WARNING); })(); } } exports.NoopTestRuntime = NoopTestRuntime; var noopRuntime = exports.noopRuntime = new NoopTestRuntime(); //# sourceMappingURL=NoopTestRuntime.js.map