UNPKG

e2ed

Version:

E2E testing framework over Playwright

42 lines (41 loc) 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getShouldRunTest = void 0; const completedTestRuns_1 = require("../completedTestRuns"); const fs_1 = require("../fs"); const uiMode_1 = require("../uiMode"); const getIsTestIncludedInPack_1 = require("./getIsTestIncludedInPack"); /** * Returns `true`, if test should be run, and `false` otherwise. * Writes all running tests into the array of `CompletedTestRun`, * and checks the uniqueness of test file path and the uniqueness of test name. * @internal */ const getShouldRunTest = async (testStaticOptions) => { const isTestIncludedInPack = (0, getIsTestIncludedInPack_1.getIsTestIncludedInPack)(testStaticOptions); if (!isTestIncludedInPack) { await (0, fs_1.writeNotIncludedInPackTest)(testStaticOptions.filePath); return false; } if (uiMode_1.isUiMode) { return true; } const completedTestRuns = await (0, fs_1.readCompletedTestRuns)(); await (0, fs_1.writeCompletedTestRun)({ ...testStaticOptions, status: 'started' }); const isTestFilePathUniq = await (0, completedTestRuns_1.getIsTestFilePathUniq)(testStaticOptions, completedTestRuns); if (isTestFilePathUniq === false) { return false; } const isTestNameUniq = await (0, completedTestRuns_1.getIsTestNameUniq)(testStaticOptions, completedTestRuns); if (isTestNameUniq === false) { return false; } for (const completedTestRun of completedTestRuns) { if (completedTestRun.filePath === testStaticOptions.filePath && (0, completedTestRuns_1.getIsSuccessfulTestRun)(completedTestRun)) { return false; } } return true; }; exports.getShouldRunTest = getShouldRunTest;