Skip to content

Commit

Permalink
Merge pull request #147 from Hargne/release/3.5.0
Browse files Browse the repository at this point in the history
Release 3.5.0
  • Loading branch information
Hargne authored Apr 27, 2022
2 parents 580445e + 0f37a5e commit 1796683
Show file tree
Hide file tree
Showing 3 changed files with 895 additions and 578 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-html-reporter",
"version": "3.4.2",
"version": "3.5.0",
"description": "Jest test results processor for generating a summary in HTML",
"main": "dist/index.js",
"unpkg": "dist/index.js",
Expand Down Expand Up @@ -56,10 +56,10 @@
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^7.1.1",
"@types/dateformat": "^3.0.X",
"@types/jest": "27.X.X",
"@types/mkdirp": "1.X.X",
"@types/jest": "27.4.0",
"@types/mkdirp": "1.0.2",
"@types/node": "12.20.12",
"@types/sinon": "9.X.X",
"@types/sinon": "9.0.11",
"babel-jest": "^27.0.1",
"jest": "^27.0.1",
"rollup": "2.47.0",
Expand Down
22 changes: 8 additions & 14 deletions src/htmlreporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class HTMLReporter {
if (this.getConfigValue("append") as boolean) {
await this.appendToFile(outputPath, report.toString());
} else {
await fs.writeFileSync(outputPath, report.toString());
fs.writeFileSync(outputPath, report.toString());
}

this.logMessage("success", `Report generated (${outputPath})`);
Expand All @@ -64,7 +64,7 @@ class HTMLReporter {
this.getConfigValue("boilerplate") as string
);

const boilerplateContent = await fs.readFileSync(boilerplatePath, "utf8");
const boilerplateContent = fs.readFileSync(boilerplatePath, "utf8");
return boilerplateContent.replace(
"{jesthtmlreporter-content}",
reportContent && reportContent.toString()
Expand Down Expand Up @@ -94,10 +94,7 @@ class HTMLReporter {
!!!this.getConfigValue("styleOverridePath");

if (inlineCSS) {
const stylesheetContent = await fs.readFileSync(
stylesheetFilePath,
"utf8"
);
const stylesheetContent = fs.readFileSync(stylesheetFilePath, "utf8");
headTag.raw(`<style type="text/css">${stylesheetContent}</style>`);
} else {
headTag.ele("link", {
Expand Down Expand Up @@ -330,7 +327,7 @@ class HTMLReporter {
* Test Suites
*/
if (sortedTestResults) {
sortedTestResults.map((suite, i) => {
sortedTestResults.forEach((suite, i) => {
// Ignore this suite if there are no results
if (!suite.testResults || suite.testResults.length <= 0) {
if (
Expand Down Expand Up @@ -674,10 +671,10 @@ class HTMLReporter {
public async appendToFile(filePath: string, content: any) {
let parsedContent = content;
// Check if the file exists or not
const fileExists = fs.existsSync(filePath)
const fileExists = fs.existsSync(filePath);
// The file exists - we need to strip all unnecessary html
if (fileExists) {
const fileToAppend = await fs.readFileSync(filePath, "utf8");
const fileToAppend = fs.readFileSync(filePath, "utf8");
const contentSearch = /<body>(.*?)<\/body>/gm.exec(content);
if (contentSearch) {
const [strippedContent] = contentSearch;
Expand Down Expand Up @@ -715,7 +712,7 @@ class HTMLReporter {

return path.resolve(
rootDir,
path.normalize("./" + filePath.substr("<rootDir>".length))
path.normalize("./" + filePath.substring("<rootDir>".length))
);
}

Expand All @@ -725,10 +722,7 @@ class HTMLReporter {
* @param message
* @param ignoreConsole
*/
public logMessage(
type: "default" | "success" | "error" = "default",
message: string
) {
public logMessage(type: "default" | "success" | "error", message: string) {
const logTypes = {
default: "\x1b[37m%s\x1b[0m",
success: "\x1b[32m%s\x1b[0m",
Expand Down
Loading

0 comments on commit 1796683

Please sign in to comment.