e2ed
Version:
E2E testing framework over Playwright
50 lines (49 loc) • 2.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.runPackWithRetries = void 0;
const config_1 = require("../config");
const end_1 = require("../end");
const generalLog_1 = require("../generalLog");
const object_1 = require("../object");
const runLabel_1 = require("../runLabel");
const afterRetries_1 = require("./afterRetries");
const runRetry_1 = require("./runRetry");
const truncateRetriesStateForLogs_1 = require("./truncateRetriesStateForLogs");
const updateRetriesStateAfterRetry_1 = require("./updateRetriesStateAfterRetry");
/**
* Runs e2ed pack of tests (or tasks) with retries.
* @internal
*/
const runPackWithRetries = async () => {
const retriesState = {
concurrency: 1,
failedTestNamesInLastRetry: [],
startLastRetryTimeInMs: 0,
successfulTestRunNamesHash: Object.create(null),
visitedTestRunEventsFileName: [],
};
try {
const { concurrency, maxRetriesCountInDocker } = (0, config_1.getFullPackConfig)();
(0, object_1.setReadonlyProperty)(retriesState, 'concurrency', concurrency);
const runLabel = (0, runLabel_1.createRunLabel)({ concurrency, maxRetriesCount: maxRetriesCountInDocker });
const startLastRetryTimeInMs = Date.now();
(0, object_1.setReadonlyProperty)(retriesState, 'startLastRetryTimeInMs', startLastRetryTimeInMs);
(0, generalLog_1.generalLog)(`Run tests (${runLabel}, concurrency ${concurrency})`, {
retriesState: (0, truncateRetriesStateForLogs_1.truncateRetriesStateForLogs)(retriesState),
});
await (0, generalLog_1.writeLogsToFile)();
await (0, runRetry_1.runRetry)({ runLabel, successfulTestRunNamesHash: retriesState.successfulTestRunNamesHash });
(0, end_1.endE2ed)("retriesCycleEnded" /* EndE2edReason.RetriesCycleEnded */);
}
catch (error) {
(0, generalLog_1.generalLog)('Caught an error on running test', {
error,
retriesState: (0, truncateRetriesStateForLogs_1.truncateRetriesStateForLogs)(retriesState),
});
}
finally {
await (0, updateRetriesStateAfterRetry_1.updateRetriesStateAfterRetry)(retriesState).catch(() => { });
(0, afterRetries_1.afterRetries)(retriesState);
}
};
exports.runPackWithRetries = runPackWithRetries;