UNPKG

html-reporter

Version:

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

56 lines 3 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const p_queue_1 = __importDefault(require("p-queue")); const static_1 = require("./lib/report-builder/static"); const plugin_api_1 = require("./lib/plugin-api"); const config_1 = require("./lib/config"); const constants_1 = require("./lib/constants"); const sqlite_client_1 = require("./lib/sqlite-client"); const image_store_1 = require("./lib/image-store"); const images_info_saver_1 = require("./lib/images-info-saver"); const cache_1 = require("./lib/cache"); const server_utils_1 = require("./lib/server-utils"); const jest_1 = require("./lib/adapters/test-result/jest"); class JestHtmlReporter { constructor(globalConfig, opts, reporterContext) { this._promiseQueue = new p_queue_1.default(); this._config = (0, config_1.parseConfig)(opts); this._globalConfig = globalConfig; this._context = reporterContext; this._htmlReporter = plugin_api_1.HtmlReporter.create(this._config, { toolName: constants_1.ToolName.Jest }); this._staticReportBuilder = null; this._initPromise = (async (htmlReporter, config) => { const dbClient = await sqlite_client_1.SqliteClient.create({ htmlReporter, reportPath: config.path }); const imageStore = new image_store_1.SqliteImageStore(dbClient); const expectedPathsCache = new cache_1.Cache(server_utils_1.getExpectedCacheKey); const imagesInfoSaver = new images_info_saver_1.ImagesInfoSaver({ imageFileSaver: htmlReporter.imagesSaver, expectedPathsCache, imageStore, reportPath: htmlReporter.config.path }); this._staticReportBuilder = static_1.StaticReportBuilder.create({ htmlReporter, reporterConfig: config, dbClient, imagesInfoSaver }); await this._staticReportBuilder.saveStaticFiles(); })(this._htmlReporter, this._config); this._promiseQueue.add(async () => this._initPromise); } // eslint-disable-next-line @typescript-eslint/no-unused-vars onTestResult(test, testResult, _aggregatedResult) { this._promiseQueue.add(async () => { await this._initPromise; const staticReportBuilder = this._staticReportBuilder; await Promise.all(testResult.testResults.map(assertion => staticReportBuilder.addTestResult(new jest_1.JestTestResultAdapter(test, testResult, assertion)))); }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars async onRunComplete(_testContexts, _results) { await this._promiseQueue.onIdle(); await this._staticReportBuilder?.finalize(); await this._htmlReporter.emitAsync(constants_1.PluginEvents.REPORT_SAVED); } } module.exports = JestHtmlReporter; //# sourceMappingURL=jest.js.map