UNPKG

e2ed

Version:

E2E testing framework over Playwright

37 lines (36 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertThatTestNamesAndFilePathsAreUniqueInOneRetry = void 0; const asserts_1 = require("../asserts"); const clone_1 = require("../clone"); const fs_1 = require("../fs"); /** * Asserts that test names and file paths inside one retry are unique. * @internal */ const assertThatTestNamesAndFilePathsAreUniqueInOneRetry = async (fullTestRuns) => { const filePathsHash = Object.create(null); const namesHash = Object.create(null); const unbrokenTestRuns = fullTestRuns.filter(({ status }) => status !== "broken" /* TestRunStatus.Broken */); for (const fullTestRun of unbrokenTestRuns) { const { filePath, name } = fullTestRun; if (filePath in filePathsHash) { const firstTestString = JSON.stringify({ name: filePathsHash[filePath].name, options: filePathsHash[filePath]?.options, }); const secondTestString = JSON.stringify({ name: fullTestRun.name, options: fullTestRun.options, }); await (0, fs_1.writeGlobalError)(`The file "${filePath}" unexpectedly contains two different tests: ${firstTestString}, ${secondTestString}`); } (0, asserts_1.assertValueIsFalse)(name in namesHash, 'name is unique: each test must have a unique name', { firstFullTestRun: (0, clone_1.cloneWithoutLogEvents)(namesHash[name]), secondFullTestRun: (0, clone_1.cloneWithoutLogEvents)(fullTestRun), }); filePathsHash[filePath] = fullTestRun; namesHash[name] = fullTestRun; } }; exports.assertThatTestNamesAndFilePathsAreUniqueInOneRetry = assertThatTestNamesAndFilePathsAreUniqueInOneRetry;