UNPKG

jest-markdown-expand-reporter

Version:

A markdown reporter for Jest tests with expandable sections containing per test console logs

35 lines (34 loc) 883 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); let ejs = null; let path = null; try { ejs = require('ejs'); } catch { } try { path = require('path'); } catch { } class MDGenerator { static async generate(runResults, date) { if (!ejs || !path) return ''; const packageName = process.env.npm_package_name; try { const templatePath = path.join(__dirname, 'testByTestTemplate.ejs'); const results = await ejs.renderFile(templatePath, { ...runResults, date, packageName, }); return results; } catch (error) { process.stderr.write(`Error generating report: ${error}\n`); // Fail silently and gracefully return ''; } } } exports.default = MDGenerator;