UNPKG

e2ed

Version:

E2E testing framework over Playwright

24 lines (23 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIsTestNameUniq = void 0; const fs_1 = require("../fs"); const getIsTestOptionsDifferent_1 = require("./getIsTestOptionsDifferent"); /** * Returns `true`, if new test file has uniq name in completed test runs, * otherwise writes global error. * @internal */ const getIsTestNameUniq = async (testStaticOptions, completedTestRuns) => { const { filePath, name, options } = testStaticOptions; const testRunsWithName = completedTestRuns.filter((run) => run.name === name); for (const completedTestRun of testRunsWithName) { if (filePath !== completedTestRun.filePath || (0, getIsTestOptionsDifferent_1.getIsTestOptionsDifferent)(options, completedTestRun.options)) { await (0, fs_1.writeGlobalError)(`There are two different tests with the same name "${name}": "${completedTestRun.filePath}" (${JSON.stringify(completedTestRun.options)}) and "${filePath}" (${JSON.stringify(options)})`); return false; } } return true; }; exports.getIsTestNameUniq = getIsTestNameUniq;