;
- useCssFile: IJestHTMLReporterConfigOption<
- IJestHTMLReporterConfigOptions["useCssFile"]
- >;
-}
+};
export interface IJestHTMLReporterConsole {
filePath: string;
diff --git a/test/htmlreporter.spec.ts b/test/htmlreporter.spec.ts
index e06b970..aa39fd6 100644
--- a/test/htmlreporter.spec.ts
+++ b/test/htmlreporter.spec.ts
@@ -182,6 +182,54 @@ describe("HTMLReporter", () => {
});
});
+ describe("includeStackTrace", () => {
+ it("should remove stack traces in failure messages if set to false", async () => {
+ const reporter = new HTMLReporter({
+ testData: mockedJestResponseSingleTestResult,
+ options: {
+ includeFailureMsg: true,
+ includeStackTrace: false,
+ },
+ });
+ const reportContent = await reporter.renderTestReportContent();
+ expect(reportContent).toBeDefined();
+ expect(
+ reportContent!
+ .toString()
+ .indexOf(
+ 'Error: failures that happened
'
+ )
+ ).not.toBe(-1);
+ });
+ it("should keep stack trace in failure messages if set to true", async () => {
+ const reporter = new HTMLReporter({
+ testData: mockedJestResponseSingleTestResult,
+ options: {
+ includeFailureMsg: true,
+ includeStackTrace: true,
+ },
+ });
+ const reportContent = await reporter.renderTestReportContent();
+ expect(reportContent).toBeDefined();
+ expect(
+ reportContent!.toString().indexOf("at stack trace")
+ ).toBeGreaterThan(-1);
+ });
+ it("should keep stack trace in failure messages if undefined", async () => {
+ const reporter = new HTMLReporter({
+ testData: mockedJestResponseSingleTestResult,
+ options: {
+ includeFailureMsg: true,
+ },
+ });
+ const reportContent = await reporter.renderTestReportContent();
+ expect(reportContent).toBeDefined();
+ expect(
+ reportContent!.toString().indexOf("at stack trace")
+ ).toBeGreaterThan(-1);
+ });
+ });
+
describe("includeSuiteFailure", () => {
it("should include suite failure message", async () => {
const reporter = new HTMLReporter({
diff --git a/test/index.spec.ts b/test/index.spec.ts
index 4fc776f..45cd0c1 100644
--- a/test/index.spec.ts
+++ b/test/index.spec.ts
@@ -3,7 +3,6 @@ import sinon, { SinonStub } from "sinon";
import JestHTMLReporter from "../src";
import {
- mockedFullReportOutput,
mockedJestGlobalConfig,
mockedJestResponseSingleTestResult,
} from "./mockdata";
@@ -12,7 +11,9 @@ describe("index", () => {
let writeFileSync: SinonStub;
beforeEach(() => {
- writeFileSync = sinon.stub(fs, "writeFileSync").returns(null as void);
+ writeFileSync = sinon
+ .stub(fs, "writeFileSync")
+ .returns(null as unknown as void);
});
afterEach(() => {
writeFileSync.restore();
diff --git a/test/mockdata/index.ts b/test/mockdata/index.ts
index 015ee31..06ccab8 100644
--- a/test/mockdata/index.ts
+++ b/test/mockdata/index.ts
@@ -99,7 +99,9 @@ export const mockedJestResponseSingleTestResult: AggregatedResult = {
title: "title",
status: "pending",
ancestorTitles: ["ancestor"],
- failureMessages: ["failure"],
+ failureMessages: [
+ "Error: failures that happened\n" + "\n" + " at stack trace",
+ ],
failureDetails: ["detailed failure"],
numPassingAsserts: 0,
fullName: "pending",
@@ -215,7 +217,9 @@ export const mockedJestResponseMultipleTestResult: AggregatedResult = {
title: "title c",
status: "failed",
ancestorTitles: ["ancestor c", "ancestor child"],
- failureMessages: ["failure"],
+ failureMessages: [
+ "Error: failures that happened\n" + "\n" + " at stack trace",
+ ],
failureDetails: ["detailed failure"],
numPassingAsserts: 0,
fullName: "failed",
@@ -279,7 +283,9 @@ export const mockedJestResponseMultipleTestResult: AggregatedResult = {
title: "title c",
status: "failed",
ancestorTitles: ["ancestor c"],
- failureMessages: ["failure"],
+ failureMessages: [
+ "Error: failures that happened\n" + "\n" + " at stack trace",
+ ],
failureDetails: ["detailed failure"],
numPassingAsserts: 0,
fullName: "failed",