UNPKG

e2ed

Version:

E2E testing framework over Playwright

28 lines (27 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.log = void 0; const runId_1 = require("../../context/runId"); const config_1 = require("../config"); // eslint-disable-next-line import/no-internal-modules const registerLogEvent_1 = require("../events/registerLogEvent"); const logWithPreparedOptions_1 = require("./logWithPreparedOptions"); /** * Logs every actions and API requests in e2ed tests. */ const log = (message, maybePayload, maybeLogEventType) => { const time = Date.now(); const runId = (0, runId_1.getRunId)(); const payload = typeof maybePayload === 'object' ? maybePayload : undefined; const type = typeof maybePayload === 'number' ? maybePayload : (maybeLogEventType ?? 9 /* LogEventType.Unspecified */); const { addLogsWithTags, mapLogPayloadInReport } = (0, config_1.getFullPackConfig)(); if (payload && 'logTag' in payload && !addLogsWithTags.includes(payload.logTag)) { return; } const payloadInReport = mapLogPayloadInReport(message, payload, type); (0, registerLogEvent_1.registerLogEvent)(runId, { message, payload: payloadInReport, time, type }); (0, logWithPreparedOptions_1.logWithPreparedOptions)(message, { payload, runId, type, utcTimeInMs: time }); }; exports.log = log;