forked from openebs/mayastor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
produce nice test reports from mocha in jenkins (CAS-448)
It makes use of xunit (standard xml test output).
- Loading branch information
Jan Kryl
committed
Sep 17, 2020
1 parent
7e309f3
commit 90a0513
Showing
5 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Mocha does not support multiple reporters running at once. So we use this | ||
// simple wrapper as suggested in: | ||
// https://github.com/mochajs/mocha/pull/1360#issuecomment-407404831 | ||
|
||
const mocha = require('mocha'); | ||
|
||
function MultiReporter (runner, options) { | ||
this.reports = []; | ||
if (!options.reporterOptions.reporters) { | ||
console.log('\nneeds --reporter-options reporters="SPACE_SEPARATED_MOCHA_REPORTS"'); | ||
return; | ||
} | ||
const self = this; | ||
options.reporterOptions.reporters.split(' ').forEach(function (report) { | ||
const ReportClass = mocha.reporters[report]; | ||
if (!ReportClass) { | ||
console.log('\ninvalid report class available: ' + Object.keys(mocha.reporters).join(',')); | ||
return; | ||
} | ||
const reportInstance = new ReportClass(runner, options); | ||
self.reports.push(reportInstance); | ||
}); | ||
} | ||
|
||
MultiReporter.prototype.epilogue = function () { | ||
this.reports.forEach(function (reportInstance) { | ||
reportInstance.epilogue(); | ||
}); | ||
}; | ||
|
||
exports = module.exports = MultiReporter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Mocha does not support multiple reporters running at once. So we use this | ||
// simple wrapper as suggested in: | ||
// https://github.com/mochajs/mocha/pull/1360#issuecomment-407404831 | ||
|
||
const mocha = require('mocha'); | ||
|
||
function MultiReporter (runner, options) { | ||
this.reports = []; | ||
if (!options.reporterOptions.reporters) { | ||
console.log('\nneeds --reporter-options reporters="SPACE_SEPARATED_MOCHA_REPORTS"'); | ||
return; | ||
} | ||
const self = this; | ||
options.reporterOptions.reporters.split(' ').forEach(function (report) { | ||
const ReportClass = mocha.reporters[report]; | ||
if (!ReportClass) { | ||
console.log('\ninvalid report class available: ' + Object.keys(mocha.reporters).join(',')); | ||
return; | ||
} | ||
const reportInstance = new ReportClass(runner, options); | ||
self.reports.push(reportInstance); | ||
}); | ||
} | ||
|
||
MultiReporter.prototype.epilogue = function () { | ||
this.reports.forEach(function (reportInstance) { | ||
reportInstance.epilogue(); | ||
}); | ||
}; | ||
|
||
exports = module.exports = MultiReporter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters