Skip to content

Commit

Permalink
Resolve undefined property lookup on mocha file name formatting (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjkipping authored Jun 16, 2023
1 parent 0289423 commit 4cc3163
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ MochaJUnitReporter.prototype.formatReportFilename = function(xml, testsuites) {
reportFilename = reportFilename.replace('[rootSuiteTitle]', this._options.rootSuiteTitle);
}
if (reportFilename.indexOf('[suiteFilename]') !== -1) {
reportFilename = reportFilename.replace('[suiteFilename]', testsuites[0].testsuite[0]._attr.file);
reportFilename = reportFilename.replace('[suiteFilename]', testsuites[0]?.testsuite[0]?._attr.file ?? 'suiteFilename');
}
if (reportFilename.indexOf('[suiteName]') !== -1) {
reportFilename = reportFilename.replace('[suiteName]', testsuites[1].testsuite[0]._attr.name);
reportFilename = reportFilename.replace('[suiteName]', testsuites[1]?.testsuite[0]?._attr.name ?? 'suiteName');
}

return reportFilename;
Expand Down

0 comments on commit 4cc3163

Please sign in to comment.