e2ed
Version:
E2E testing framework over Playwright
40 lines (39 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addTestToNotIncludedInPackTests = exports.getNotIncludedInPackTests = void 0;
const promises_1 = require("node:fs/promises");
const node_path_1 = require("node:path");
const internal_1 = require("../constants/internal");
const asserts_1 = require("./asserts");
/**
* Relative (from root) path to text file with list of not included in pack tests.
* For each not included in pack test in this file, a relative path
* to the file of this test is saved in a separate line.
*/
const NOT_INCLUDED_IN_PACK_TESTS_PATH = (0, node_path_1.join)(internal_1.TMP_DIRECTORY_PATH, 'notIncludedInPackTests.txt');
/**
* Get array of not included in pack tests.
* @internal
*/
const getNotIncludedInPackTests = async () => {
let textOfNotIncludedInPackTestsFile = '';
try {
textOfNotIncludedInPackTestsFile = await (0, promises_1.readFile)(NOT_INCLUDED_IN_PACK_TESTS_PATH, internal_1.READ_FILE_OPTIONS);
}
catch { }
return textOfNotIncludedInPackTestsFile
.split('\n')
.map((line) => line.trim())
.filter(Boolean);
};
exports.getNotIncludedInPackTests = getNotIncludedInPackTests;
/**
* Adds test to not included in pack tests.
* @internal
*/
const addTestToNotIncludedInPackTests = async (testFilePath) => {
const notIncludedInPackTests = await (0, exports.getNotIncludedInPackTests)();
(0, asserts_1.assertValueIsFalse)(notIncludedInPackTests.includes(testFilePath), 'There is no duplicate test file path in not included in pack tests', { notIncludedInPackTests, testFilePath });
await (0, promises_1.appendFile)(NOT_INCLUDED_IN_PACK_TESTS_PATH, `${testFilePath}\n`);
};
exports.addTestToNotIncludedInPackTests = addTestToNotIncludedInPackTests;