UNPKG

html-reporter

Version:

Html-reporter and GUI for viewing and managing results of a tests run. Currently supports Testplane and Hermione.

87 lines 3.92 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = exports.commands = void 0; const node_path_1 = __importDefault(require("node:path")); const lodash_1 = __importDefault(require("lodash")); const commander_1 = require("@gemini-testing/commander"); const package_json_1 = __importDefault(require("../../package.json")); const constants_1 = require("../constants"); const tool_1 = require("../adapters/tool"); const common_utils_1 = require("../common-utils"); exports.commands = { GUI: 'gui', MERGE_REPORTS: 'merge-reports', REMOVE_UNUSED_SCREENS: 'remove-unused-screens' }; let toolAdapter; process.on('uncaughtException', err => { common_utils_1.logger.error(err.stack); process.exit(1); }); process.on('unhandledRejection', (reason, p) => { const error = new Error([ `Unhandled Rejection in ${toolAdapter ? toolAdapter.toolName + ':' : ''}${process.pid}:`, `Promise: ${JSON.stringify(p)}`, `Reason: ${lodash_1.default.get(reason, 'stack', reason)}` ].join('\n')); if (toolAdapter) { toolAdapter.halt(error, 60000); } else { common_utils_1.logger.error(error); process.exit(1); } }); const run = async () => { const program = new commander_1.Command(package_json_1.default.name) .version(package_json_1.default.version) .allowUnknownOption() .option('-c, --config <path>', 'path to configuration file') .option('-t, --tool <toolName>', 'tool name which should be run', constants_1.ToolName.Testplane); const { tool: toolName, config: configPath } = preparseOptions(program, ['config', 'tool']); const availableToolNames = Object.values(constants_1.ToolName); if (!availableToolNames.includes(toolName)) { throw new Error(`Tool with name: "${toolName}" is not supported, try to use one of these: ${availableToolNames.map(t => `"${t}"`).join(', ')}`); } toolAdapter = await (0, tool_1.makeToolAdapter)({ toolName: toolName, configPath }); for (const commandName of lodash_1.default.values(exports.commands)) { const registerCmd = (await Promise.resolve(`${node_path_1.default.resolve(__dirname, './commands', commandName)}`).then(s => __importStar(require(s)))).default; registerCmd(program, toolAdapter); } program.parse(process.argv); }; exports.run = run; function preparseOptions(program, options) { const configFileParser = Object.create(program); configFileParser.options = [].concat(program.options); configFileParser.option('-h, --help'); configFileParser.parse(process.argv); return options.reduce((acc, val) => lodash_1.default.set(acc, val, configFileParser[val]), {}); } //# sourceMappingURL=index.js.map