UNPKG

e2ed

Version:

E2E testing framework over Playwright

34 lines (33 loc) 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getReportErrors = void 0; const config_1 = require("../config"); const fs_1 = require("../fs"); const testFilePaths_1 = require("../testFilePaths"); /** * Get all report errors and warnings. General report status is failed if there is any error. * @internal */ const getReportErrors = async (fullTestRuns, notIncludedInPackTests) => { const { testFileGlobs } = (0, config_1.getFullPackConfig)(); const errors = (await (0, fs_1.readGlobalErrors)()); const warnings = await (0, fs_1.readGlobalWarnings)(); const allTestFilePaths = await (0, testFilePaths_1.collectTestFilePaths)(); const unsuccessfulTestFilePaths = await (0, testFilePaths_1.getUnsuccessfulTestFilePaths)(allTestFilePaths, notIncludedInPackTests); const unvisitedTestFilePaths = (0, testFilePaths_1.getUnvisitedTestFilePaths)(fullTestRuns, allTestFilePaths, notIncludedInPackTests); const unsuccessfulCount = unsuccessfulTestFilePaths.length; const unvisitedCount = unvisitedTestFilePaths.length; const thereAreManyUnsuccessfulFiles = unsuccessfulCount > 1; const thereAreManyUnvisitedFiles = unvisitedCount > 1; const wordTest = thereAreManyUnsuccessfulFiles ? 'tests' : 'test'; const wordFile = thereAreManyUnvisitedFiles ? 'files' : 'file'; const wordGlob = testFileGlobs.length > 1 ? 'globs' : 'glob'; if (unsuccessfulCount !== 0) { errors.push(`Error: There ${thereAreManyUnsuccessfulFiles ? 'are' : 'is'} ${unsuccessfulCount} unsuccessful ${wordTest}: ${unsuccessfulTestFilePaths.join(', ')}`); } if (unvisitedCount !== 0) { errors.push(`Error: There ${thereAreManyUnvisitedFiles ? 'are' : 'is'} ${unvisitedCount} test ${wordFile} found by the ${wordGlob} "${testFileGlobs.join(', ')}" and not visited when running tests: ${unvisitedTestFilePaths.join(', ')}`); } return { errors, warnings }; }; exports.getReportErrors = getReportErrors;