diff --git a/src/helpers/report-builder.cjs b/src/helpers/report-builder.cjs index 2eae798..2a1607c 100644 --- a/src/helpers/report-builder.cjs +++ b/src/helpers/report-builder.cjs @@ -58,7 +58,7 @@ class ReportBuilderBase { this._data = {}; } - toJSON() { + get data() { return this._data; } @@ -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; } @@ -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) { @@ -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) { @@ -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) }; }