e2ed
Version:
E2E testing framework over Playwright
30 lines (29 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.runAfterPackFunctions = void 0;
const config_1 = require("../config");
const generalLog_1 = require("../generalLog");
const object_1 = require("../object");
const userland_1 = require("../userland");
/**
* Runs functions from `doAfterPack` pack config field.
* @internal
*/
const runAfterPackFunctions = async (liteReport) => {
const { doAfterPack: functions } = (0, config_1.getFullPackConfig)();
const args = [liteReport];
const processCurrentFunctionResult = (result) => {
if (result === undefined) {
return;
}
(0, object_1.setReadonlyProperty)(liteReport, 'customReportProperties', result);
};
const functionNames = functions.map(({ name }) => name || 'anonymous').join(', ');
const message = functions.length > 0
? `Will be run ${functions.length} after pack function${functions.length > 1 ? 's' : ''} (${functionNames})`
: 'There are no after pack functions';
(0, generalLog_1.generalLog)(message);
const afterPackExecutionTimeWithUnits = await (0, userland_1.runArrayOfUserlandFunctions)(functions, () => args, processCurrentFunctionResult);
(0, object_1.setReadonlyProperty)(liteReport, 'afterPackExecutionTimeWithUnits', afterPackExecutionTimeWithUnits);
};
exports.runAfterPackFunctions = runAfterPackFunctions;