Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
use suite hierarchy for reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
esalman-sfdc committed Mar 20, 2018
1 parent c21dc39 commit e503cbe
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,23 @@
*/
$T._sfdxReportForJasmine = function (jasmine) {
var run_results_full = { "tests": [] };
var suiteDescription = '';
var suiteDescription = [];
var specStartTime = 0;

var sfdxReporter = {
suiteStarted: function(suite) {
suiteDescription = suite.description;
suiteDescription.push(suite.description);
},
suiteDone: function(suite) {
suiteDescription.pop();
},
specStarted: function(spec) {
specStartTime = Date.now();
},
specDone: function(spec) {
var fullReport = {};
var failedStr = '';
fullReport.FullName = suiteDescription + ' : ' + spec.description;
fullReport.FullName = suiteDescription.join(' : ') + ' : ' + spec.description;
fullReport.Outcome = 'Pass';
fullReport.RunTime = Date.now() - specStartTime;

Expand All @@ -168,7 +171,6 @@
console.log('failed!', fullReport.FullName, '- ' + fullReport.RunTime + 'ms');
for (var i = 0, failure; i < spec.failedExpectations.length; i++) {
var failureMessage = spec.failedExpectations[i].message;
failureMessage.replace(/^\s+/, "" ).replace(/\s+$/, "" );
failedStr += '\n ' + failureMessage;
}

Expand Down Expand Up @@ -214,13 +216,22 @@
var convertMochaTestEventToSfdxTestResult = function (test) {
console.log(test.state + '!', test.title, '-' + test.duration + 'ms');
return {
FullName: test.parent.title + ' : ' + test.title,
FullName: generateMochaTestTitleForSfdx(test),
Outcome: mochaStateToOutcome[test.state],
RunTime: test.duration,
Message: test.err ? test.err.message : undefined
};
};

var generateMochaTestTitleForSfdx = function (test) {
var sfdxTitle = test.title;
while (!test.parent.root) {
sfdxTitle = test.parent.title + ' : ' + sfdxTitle;
test = test.parent;
}
return sfdxTitle.replace(/["]/g, "'");
}

var mochaStateToOutcome = {
'passed': 'Pass',
'failed': 'Failed',
Expand Down

0 comments on commit e503cbe

Please sign in to comment.