Skip to content

Commit

Permalink
[Newman]: fix markdown description (#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw authored Feb 16, 2024
1 parent 95cac06 commit a13bbdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
27 changes: 10 additions & 17 deletions packages/newman-reporter-allure/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,14 @@ class AllureReporter {
}
}

setDescriptionHtml(html: string) {
if (html) {
this.currentExecutable.descriptionHtml = html;
}
setDescription(markdown: string) {
this.currentExecutable.description = markdown;
}

setDescriptionHtml(markdown: string) {
const htmlDescription = markdown.replace(/[*]/g, "").replace(/\n/g, "<br>");

this.currentExecutable.descriptionHtml = htmlDescription;
}

endTest(allureTest: AllureTest, status: Status, details?: StatusDetails) {
Expand Down Expand Up @@ -355,20 +359,8 @@ class AllureReporter {
this.currentExecutable.addAttachment("Request Body", { contentType: ContentType.TEXT }, attachment);
}

let testDescription = "";

const rawDescription = args.item.request.description;

if (rawDescription !== undefined) {
if (typeof rawDescription === "string") {
testDescription = rawDescription || "";
} else {
testDescription = rawDescription.content || "";
}

testDescription = testDescription.replace(/[*]/g, "");
testDescription = testDescription.replace(/\n/g, "<br>");
}
const testDescription = (typeof rawDescription === "string" ? rawDescription : rawDescription?.content) || "";

if (requestDataURL) {
this.currentExecutable.parameter("Request", requestDataURL);
Expand All @@ -383,6 +375,7 @@ class AllureReporter {
}

if (testDescription) {
this.setDescription(testDescription);
this.setDescriptionHtml(testDescription);
}

Expand Down
1 change: 1 addition & 0 deletions packages/newman-reporter-allure/test/specs/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ test("complex test overview", async () => {
parameters: [],
name: "Status code is 200",
});
expect(result.description).toBe("testDescription\n\nmultiline\n\n**somethingBold**");
expect(result.descriptionHtml).toBe("testDescription<br><br>multiline<br><br>somethingBold");
expect(result.labels).toEqual([
{ name: "parentSuite", value: "ParentName" },
Expand Down

0 comments on commit a13bbdd

Please sign in to comment.