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 bf5dcd1
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/helpers/report-builder.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ class ReportBuilderBase {
this._data = {};
}

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

toJSON() {
return this.data;
}

_setProperty(key, value, { override = false } = {}) {
if (override) {
this._data[key] = value;
Expand Down Expand Up @@ -187,7 +191,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 +356,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 +373,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 +400,10 @@ class ReportBuilder extends ReportBuilderBase {
}

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

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

Expand Down

0 comments on commit bf5dcd1

Please sign in to comment.