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 5ab89d9
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 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,9 @@ 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: detailData }] of this._data.details) {
const detail = detailData;
const { status, retries } = detail;

if (status === 'passed') {
if (retries !== 0) {
Expand All @@ -366,7 +369,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 +396,10 @@ class ReportBuilder extends ReportBuilderBase {
}

toJSON() {
const data = super.toJSON();

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

Expand Down

0 comments on commit 5ab89d9

Please sign in to comment.