UNPKG

e2ed

Version:

E2E testing framework over Playwright

28 lines (27 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runArrayOfUserlandFunctions = void 0; const error_1 = require("../error"); const getDurationWithUnits_1 = require("../getDurationWithUnits"); /** * Run array of userland function (from `doBeforePack`/`doAfterPack`). * @internal */ const runArrayOfUserlandFunctions = async (functions, getCurrentFunctionArgs, processCurrentFunctionResult) => { const startTimeInMs = Date.now(); let args; for (const fn of functions) { try { args = getCurrentFunctionArgs(); // eslint-disable-next-line @typescript-eslint/await-thenable const result = await fn(...args); processCurrentFunctionResult(result); } catch (cause) { throw new error_1.E2edError('Caught an error on running userland function', { args, cause, fn }); } } const executionTimeWithUnits = (0, getDurationWithUnits_1.getDurationWithUnits)(Date.now() - startTimeInMs); return executionTimeWithUnits; }; exports.runArrayOfUserlandFunctions = runArrayOfUserlandFunctions;