UNPKG

e2ed

Version:

E2E testing framework over Playwright

32 lines (31 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getExitCode = void 0; const internal_1 = require("../../constants/internal"); const asserts_1 = require("../asserts"); const globalExitCode_1 = require("./globalExitCode"); /** * Get e2ed exit code by `hasError` flag and array of retries. * @internal */ const getExitCode = (hasError, retries) => { const globalExitCode = (0, globalExitCode_1.getGlobalExitCode)(); if (globalExitCode !== undefined) { return globalExitCode; } if (hasError) { return 2 /* ExitCode.HasErrors */; } if (retries.length === 0) { return 3 /* ExitCode.NoRetries */; } const lastRetry = retries.at(-1); (0, asserts_1.assertValueIsDefined)(lastRetry, 'lastRetry is defined', { retries }); const { fullTestRuns } = lastRetry; const hasFailedTests = fullTestRuns.some(({ status }) => internal_1.FAILED_TEST_RUN_STATUSES.includes(status)); if (hasFailedTests) { return 1 /* ExitCode.Failed */; } return 0 /* ExitCode.Passed */; }; exports.getExitCode = getExitCode;