Socket
Socket
Sign inDemoInstall

jest-html-reporter

Package Overview
Dependencies
518
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

93

dist/main.js

@@ -83,2 +83,5 @@ 'use strict';

const getSort = () =>
config.sort || process.env.JEST_HTML_REPORTER_SORT || 'default';
var config_1 = {

@@ -93,4 +96,70 @@ config,

getDateFormat,
getSort,
};
var sorting = createCommonjsModule(function (module) {
/**
* Splits test suites apart based on individual test status and sorts by that status:
* 1. Pending
* 2. Failed
* 3. Passed
* @param {Object} suiteResults
*/
const sortSuiteResultsByStatus = (suiteResults) => {
const pendingSuites = [];
const failingSuites = [];
const passingSuites = [];
suiteResults.forEach((suiteResult) => {
const pending = [];
const failed = [];
const passed = [];
suiteResult.testResults.forEach((x) => {
if (x.status === 'pending') {
pending.push(x);
} else if (x.status === 'failed') {
failed.push(x);
} else {
passed.push(x);
}
});
if (pending.length) {
pendingSuites.push(Object.assign({}, suiteResult, { testResults: pending }));
}
if (failed.length) {
failingSuites.push(Object.assign({}, suiteResult, { testResults: failed }));
}
if (passed.length) {
passingSuites.push(Object.assign({}, suiteResult, { testResults: passed }));
}
});
return [].concat(pendingSuites, failingSuites, passingSuites);
};
/**
* Sorts test suite results
* If sort is undefined or is not a supported value this has no effect
* @param {Object} suiteResults
* @param {String} sort The configured sort
*/
const sortSuiteResults = (suiteResults, sort) => {
if (sort === 'status') {
return sortSuiteResultsByStatus(suiteResults);
}
return suiteResults;
};
module.exports = {
sortSuiteResults,
sortSuiteResultsByStatus,
};
});
var sorting_1 = sorting.sortSuiteResults;
var sorting_2 = sorting.sortSuiteResultsByStatus;
var methods = createCommonjsModule(function (module) {

@@ -118,2 +187,12 @@ /**

/**
* Processes an array of test suite results
* @param {Object} suiteResults
* @return {Object}
*/
const processSuiteResults = (suiteResults) => {
const processedTestResults = sorting.sortSuiteResults(suiteResults, config_1.getSort());
return processedTestResults;
};
/**
* Creates a file at the given destination

@@ -190,4 +269,6 @@ * @param {String} filePath

const processedSuiteResults = processSuiteResults(testData.testResults);
// Test Suites
testData.testResults.forEach((suite) => {
processedSuiteResults.forEach((suite) => {
if (!suite.testResults || suite.testResults.length <= 0) { return; }

@@ -255,2 +336,3 @@

logMessage,
processSuiteResults,
writeFile,

@@ -264,6 +346,7 @@ createReport,

var methods_1 = methods.logMessage;
var methods_2 = methods.writeFile;
var methods_3 = methods.createReport;
var methods_4 = methods.createHtml;
var methods_5 = methods.renderHTML;
var methods_2 = methods.processSuiteResults;
var methods_3 = methods.writeFile;
var methods_4 = methods.createReport;
var methods_5 = methods.createHtml;
var methods_6 = methods.renderHTML;

@@ -270,0 +353,0 @@ var src = createCommonjsModule(function (module) {

2

dist/main.min.js

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),mkdirp=_interopDefault(require("mkdirp")),xmlbuilder=_interopDefault(require("xmlbuilder")),stripAnsi=_interopDefault(require("strip-ansi")),dateformat=_interopDefault(require("dateformat"));function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}const config={};try{const e=fs.readFileSync(path.join(process.cwd(),"package.json"),"utf8");e&&Object.assign(config,JSON.parse(e)["jest-html-reporter"])}catch(e){}try{const e=fs.readFileSync(path.join(process.cwd(),"jesthtmlreporter.config.json"),"utf8");e&&Object.assign(config,JSON.parse(e))}catch(e){}const getOutputFilepath=()=>config.outputPath||process.env.JEST_HTML_REPORTER_OUTPUT_PATH||path.join(process.cwd(),"test-report.html"),getTheme=()=>config.theme||process.env.JEST_HTML_REPORTER_THEME||"defaultTheme",getStylesheetFilepath=()=>config.styleOverridePath||process.env.JEST_HTML_REPORTER_STYLE_OVERRIDE_PATH||path.join(__dirname,`../style/${getTheme()}.css`),getPageTitle=()=>config.pageTitle||process.env.JEST_HTML_REPORTER_PAGE_TITLE||"Test report",shouldIncludeFailureMessages=()=>config.includeFailureMsg||process.env.JEST_HTML_REPORTER_INCLUDE_FAILURE_MSG||!1,getExecutionTimeWarningThreshold=()=>config.executionTimeWarningThreshold||process.env.JEST_HTML_REPORTER_EXECUTION_TIME_WARNING_THRESHOLD||5,getDateFormat=()=>config.dateFormat||process.env.JEST_HTML_REPORTER_DATE_FORMAT||"yyyy-mm-dd HH:MM:ss";var config_1={config:config,getOutputFilepath:getOutputFilepath,getStylesheetFilepath:getStylesheetFilepath,getPageTitle:getPageTitle,shouldIncludeFailureMessages:shouldIncludeFailureMessages,getExecutionTimeWarningThreshold:getExecutionTimeWarningThreshold,getTheme:getTheme,getDateFormat:getDateFormat},methods=createCommonjsModule(function(e){const t=({type:e,msg:t,ignoreConsole:s})=>{const r={default:"%s",success:"%s",error:"%s"},o=r[e]?r[e]:r.default,i=`jest-html-reporter >> ${t}`;return s||console.log(o,i),{logColor:o,logMsg:i}},s=(e,t)=>new Promise((s,r)=>{mkdirp(path.dirname(e),o=>o?r(new Error(`Something went wrong when creating the file: ${o}`)):s(fs.writeFile(e,t)))}),r=e=>xmlbuilder.create({html:{head:{meta:{"@charset":"utf-8"},title:{"#text":config_1.getPageTitle()},style:{"@type":"text/css","#text":e}},body:{h1:{"@id":"title","#text":config_1.getPageTitle()}}}}),o=(e,t)=>new Promise((s,o)=>{if(!e)return o(new Error("Test data missing or malformed"));const i=r(t),n=i.ele("div",{id:"metadata-container"}),a=new Date(e.startTime);return n.ele("div",{id:"timestamp"},`Start: ${dateformat(a,config_1.getDateFormat())}`),n.ele("div",{id:"summary"},`\n\t\t${e.numTotalTests} tests --\n\t\t${e.numPassedTests} passed /\n\t\t${e.numFailedTests} failed /\n\t\t${e.numPendingTests} pending\n\t`),e.testResults.forEach(e=>{if(!e.testResults||e.testResults.length<=0)return;const t=i.ele("div",{class:"suite-info"});t.ele("div",{class:"suite-path"},e.testFilePath);const s=(e.perfStats.end-e.perfStats.start)/1e3;t.ele("div",{class:`suite-time${s>5?" warn":""}`},`${s}s`);const r=i.ele("table",{class:"suite-table",cellspacing:"0",cellpadding:"0"});e.testResults.forEach(e=>{const t=r.ele("tr",{class:e.status});t.ele("td",{class:"suite"},e.ancestorTitles.join(" > "));const s=t.ele("td",{class:"test"},e.title);if(e.failureMessages&&config_1.shouldIncludeFailureMessages()){const t=s.ele("div",{class:"failureMessages"});e.failureMessages.forEach(e=>{t.ele("p",{class:"failureMsg"},stripAnsi(e))})}t.ele("td",{class:"result"},"passed"===e.status?`${e.status} in ${e.duration/1e3}s`:e.status)})}),s(i)});e.exports={logMessage:t,writeFile:s,createReport:(e,r)=>{const i=config_1.getOutputFilepath();return(()=>new Promise((e,t)=>{const s=config_1.getStylesheetFilepath();fs.readFile(s,"utf8",(r,o)=>r?t(new Error(`Could not locate the stylesheet: '${s}': ${r}`)):e(o))}))().then(o.bind(null,e)).then(s.bind(null,i)).then(()=>t({type:"success",msg:`Report generated (${i})`,ignoreConsole:r})).catch(e=>t({type:"error",msg:e,ignoreConsole:r}))},createHtml:r,renderHTML:o}}),methods_1=methods.logMessage,methods_2=methods.writeFile,methods_3=methods.createReport,methods_4=methods.createHtml,methods_5=methods.renderHTML,src=createCommonjsModule(function(e){e.exports=(e=>(methods.createReport(e),e))});module.exports=src;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),mkdirp=_interopDefault(require("mkdirp")),xmlbuilder=_interopDefault(require("xmlbuilder")),stripAnsi=_interopDefault(require("strip-ansi")),dateformat=_interopDefault(require("dateformat"));function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}const config={};try{const e=fs.readFileSync(path.join(process.cwd(),"package.json"),"utf8");e&&Object.assign(config,JSON.parse(e)["jest-html-reporter"])}catch(e){}try{const e=fs.readFileSync(path.join(process.cwd(),"jesthtmlreporter.config.json"),"utf8");e&&Object.assign(config,JSON.parse(e))}catch(e){}const getOutputFilepath=()=>config.outputPath||process.env.JEST_HTML_REPORTER_OUTPUT_PATH||path.join(process.cwd(),"test-report.html"),getTheme=()=>config.theme||process.env.JEST_HTML_REPORTER_THEME||"defaultTheme",getStylesheetFilepath=()=>config.styleOverridePath||process.env.JEST_HTML_REPORTER_STYLE_OVERRIDE_PATH||path.join(__dirname,`../style/${getTheme()}.css`),getPageTitle=()=>config.pageTitle||process.env.JEST_HTML_REPORTER_PAGE_TITLE||"Test report",shouldIncludeFailureMessages=()=>config.includeFailureMsg||process.env.JEST_HTML_REPORTER_INCLUDE_FAILURE_MSG||!1,getExecutionTimeWarningThreshold=()=>config.executionTimeWarningThreshold||process.env.JEST_HTML_REPORTER_EXECUTION_TIME_WARNING_THRESHOLD||5,getDateFormat=()=>config.dateFormat||process.env.JEST_HTML_REPORTER_DATE_FORMAT||"yyyy-mm-dd HH:MM:ss",getSort=()=>config.sort||process.env.JEST_HTML_REPORTER_SORT||"default";var config_1={config:config,getOutputFilepath:getOutputFilepath,getStylesheetFilepath:getStylesheetFilepath,getPageTitle:getPageTitle,shouldIncludeFailureMessages:shouldIncludeFailureMessages,getExecutionTimeWarningThreshold:getExecutionTimeWarningThreshold,getTheme:getTheme,getDateFormat:getDateFormat,getSort:getSort},sorting=createCommonjsModule(function(e){const t=e=>{const t=[],s=[],r=[];return e.forEach(e=>{const o=[],n=[],i=[];e.testResults.forEach(e=>{"pending"===e.status?o.push(e):"failed"===e.status?n.push(e):i.push(e)}),o.length&&t.push(Object.assign({},e,{testResults:o})),n.length&&s.push(Object.assign({},e,{testResults:n})),i.length&&r.push(Object.assign({},e,{testResults:i}))}),[].concat(t,s,r)};e.exports={sortSuiteResults:(e,s)=>"status"===s?t(e):e,sortSuiteResultsByStatus:t}}),sorting_1=sorting.sortSuiteResults,sorting_2=sorting.sortSuiteResultsByStatus,methods=createCommonjsModule(function(e){const t=({type:e,msg:t,ignoreConsole:s})=>{const r={default:"%s",success:"%s",error:"%s"},o=r[e]?r[e]:r.default,n=`jest-html-reporter >> ${t}`;return s||console.log(o,n),{logColor:o,logMsg:n}},s=e=>{return sorting.sortSuiteResults(e,config_1.getSort())},r=(e,t)=>new Promise((s,r)=>{mkdirp(path.dirname(e),o=>o?r(new Error(`Something went wrong when creating the file: ${o}`)):s(fs.writeFile(e,t)))}),o=e=>xmlbuilder.create({html:{head:{meta:{"@charset":"utf-8"},title:{"#text":config_1.getPageTitle()},style:{"@type":"text/css","#text":e}},body:{h1:{"@id":"title","#text":config_1.getPageTitle()}}}}),n=(e,t)=>new Promise((r,n)=>{if(!e)return n(new Error("Test data missing or malformed"));const i=o(t),a=i.ele("div",{id:"metadata-container"}),l=new Date(e.startTime);return a.ele("div",{id:"timestamp"},`Start: ${dateformat(l,config_1.getDateFormat())}`),a.ele("div",{id:"summary"},`\n\t\t${e.numTotalTests} tests --\n\t\t${e.numPassedTests} passed /\n\t\t${e.numFailedTests} failed /\n\t\t${e.numPendingTests} pending\n\t`),s(e.testResults).forEach(e=>{if(!e.testResults||e.testResults.length<=0)return;const t=i.ele("div",{class:"suite-info"});t.ele("div",{class:"suite-path"},e.testFilePath);const s=(e.perfStats.end-e.perfStats.start)/1e3;t.ele("div",{class:`suite-time${s>5?" warn":""}`},`${s}s`);const r=i.ele("table",{class:"suite-table",cellspacing:"0",cellpadding:"0"});e.testResults.forEach(e=>{const t=r.ele("tr",{class:e.status});t.ele("td",{class:"suite"},e.ancestorTitles.join(" > "));const s=t.ele("td",{class:"test"},e.title);if(e.failureMessages&&config_1.shouldIncludeFailureMessages()){const t=s.ele("div",{class:"failureMessages"});e.failureMessages.forEach(e=>{t.ele("p",{class:"failureMsg"},stripAnsi(e))})}t.ele("td",{class:"result"},"passed"===e.status?`${e.status} in ${e.duration/1e3}s`:e.status)})}),r(i)});e.exports={logMessage:t,processSuiteResults:s,writeFile:r,createReport:(e,s)=>{const o=config_1.getOutputFilepath();return(()=>new Promise((e,t)=>{const s=config_1.getStylesheetFilepath();fs.readFile(s,"utf8",(r,o)=>r?t(new Error(`Could not locate the stylesheet: '${s}': ${r}`)):e(o))}))().then(n.bind(null,e)).then(r.bind(null,o)).then(()=>t({type:"success",msg:`Report generated (${o})`,ignoreConsole:s})).catch(e=>t({type:"error",msg:e,ignoreConsole:s}))},createHtml:o,renderHTML:n}}),methods_1=methods.logMessage,methods_2=methods.processSuiteResults,methods_3=methods.writeFile,methods_4=methods.createReport,methods_5=methods.createHtml,methods_6=methods.renderHTML,src=createCommonjsModule(function(e){e.exports=(e=>(methods.createReport(e),e))});module.exports=src;
{
"name": "jest-html-reporter",
"version": "1.1.0",
"version": "1.2.0",
"description": "Jest test results processor for generating a summary in HTML",

@@ -5,0 +5,0 @@ "main": "dist/main",

@@ -63,2 +63,3 @@ <p align="center">

| `dateFormat` | `STRING` | The format in which date/time should be formatted in the test report. Have a look in the [Wiki](https://github.com/Hargne/jest-html-reporter/wiki/Date-Format) for the available date format variables. | `"yyyy-mm-dd HH:MM:ss"`
| `sort` | `STRING` | Sorts the test results with the given method. Available methods are: `"default"`, `"status"` More information can be found in the [Wiki](https://github.com/Hargne/jest-html-reporter/wiki/Sorting-Methods). | `"default"`

@@ -123,2 +124,3 @@ #### *A note on styleOverridePath

* `JEST_HTML_REPORTER_DATE_FORMAT`
* `JEST_HTML_REPORTER_SORT`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc