Innovenergy_trunk/frontend/node_modules/testcafe/lib/api/wrap-test-function.js

47 lines
7.0 KiB
JavaScript
Raw Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const test_run_tracker_1 = __importDefault(require("./test-run-tracker"));
const test_controller_1 = __importDefault(require("./test-controller"));
const error_list_1 = __importDefault(require("../errors/error-list"));
const test_run_1 = require("../errors/test-run");
const add_rendered_warning_1 = __importDefault(require("../notifications/add-rendered-warning"));
const warning_message_1 = __importDefault(require("../notifications/warning-message"));
const add_message_1 = require("./test-controller/add-message");
const defaultExecutor = async function ({ testRun, fn }) {
const markeredfn = test_run_tracker_1.default.addTrackingMarkerToFunction(testRun.id, fn);
return await markeredfn(testRun.controller);
};
function wrapTestFunction(fn, executor = defaultExecutor) {
return async (testRun, functionArgs) => {
let result = null;
const errList = new error_list_1.default();
testRun.controller = new test_controller_1.default(testRun);
testRun.observedCallsites.clear();
test_run_tracker_1.default.ensureEnabled();
try {
result = await executor({ fn, functionArgs, testRun });
}
catch (err) {
errList.addError(err);
}
if (!errList.hasUncaughtErrorsInTestCode) {
for (const { callsite, actionId } of testRun.observedCallsites.awaitedSnapshotWarnings.values()) {
(0, add_rendered_warning_1.default)(testRun.warningLog, {
message: warning_message_1.default.excessiveAwaitInAssertion,
actionId,
}, callsite);
}
(0, add_message_1.addWarnings)(testRun.observedCallsites.unawaitedSnapshotCallsites, warning_message_1.default.missingAwaitOnSnapshotProperty, testRun);
(0, add_message_1.addErrors)(testRun.observedCallsites.callsitesWithoutAwait, test_run_1.MissingAwaitError, errList);
}
if (errList.hasErrors)
throw errList;
return result;
};
}
exports.default = wrapTestFunction;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid3JhcC10ZXN0LWZ1bmN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi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