Skip to content

Commit

Permalink
fix: trim test name
Browse files Browse the repository at this point in the history
  • Loading branch information
devpow112 committed Nov 27, 2024
1 parent 8214cca commit 839d29b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/helpers/report-builder.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ReportBuilderBase {
this._data = {};
}

toJSON() {
get data() {
return this._data;
}

Expand Down Expand Up @@ -187,7 +187,9 @@ class ReportDetailBuilder extends ReportBuilderBase {
}

setName(name, options) {
this._setProperty('name', escapeSpecialCharacters(name), options);
const sanitizedName = escapeSpecialCharacters(name.trim());

this._setProperty('name', sanitizedName, options);

return this;
}
Expand Down Expand Up @@ -350,8 +352,8 @@ class ReportBuilder extends ReportBuilderBase {
let countSkipped = 0;
let countFlaky = 0;

for (const [, detail] of this._data.details) {
const { status, retries } = detail.toJSON();
for (const [, { data: detail }] of this._data.details) {
const { status, retries } = detail;

if (status === 'passed') {
if (retries !== 0) {
Expand All @@ -366,7 +368,7 @@ class ReportBuilder extends ReportBuilderBase {
}

if (this._verbose) {
const { name, location, type, tool, experience } = detail.toJSON();
const { name, location, type, tool, experience } = detail;
const prefix = `Test '${name}' at '${location}' is missing`;

if (!type) {
Expand All @@ -393,12 +395,12 @@ class ReportBuilder extends ReportBuilderBase {
}

toJSON() {
const data = super.toJSON();
const { summary, details } = this.data;

return {
...data,
summary: data.summary.toJSON(),
details: [...data.details].map(([, detail]) => detail.toJSON())
...this.data,
summary: summary.data,
details: [...details.values()].map(({ data }) => data)
};
}

Expand Down

0 comments on commit 839d29b

Please sign in to comment.