Last active
January 3, 2016 19:59
-
-
Save fonzerelly/8512184 to your computer and use it in GitHub Desktop.
Based on TextReporter proposed on Stackoverflow:
http://stackoverflow.com/questions/13366318/how-to-return-jasmine-unit-test-results-as-a-string
This file contains hidden or 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
TextReporter.prototype = new jasmine.Reporter(); | |
TextReporter.prototype.onRunnerFinished = function (callback) { | |
this.callbackEnd = callback; | |
}; | |
TextReporter.prototype.reportRunnerResults = function (runner) { | |
// When all the spec are finished // | |
var result = runner.results(); | |
this.textResult += "Test results :: (" + result.passedCount + "/" + result.totalCount + ") :: " + (result.passed() ? "passed" : "failed"); | |
this.textResult += "\r\n"; | |
if (this.callbackEnd) { | |
this.callbackEnd(this.textResult); | |
} | |
}; | |
TextReporter.prototype.reportSuiteResults = function (suite) { | |
// When a group of spec has finished running // | |
var result = suite.results(); | |
var description = suite.description; | |
}; | |
TextReporter.prototype.reportSpecResults = function(spec) { | |
// When a single spec has finished running // | |
var result = spec.results(); | |
var that = this; | |
that.textResult += "Spec :: " + spec.description + " :: " + (result.passed() ? "passed" : "failed"); | |
that.textResult += "\r\n"; | |
/**** Added to report Error-Mesages during the test execution ***/ | |
if (!result.passed()) { | |
spec.results().getItems().forEach(function (item) { | |
if (!item.passed()) { | |
that.textResult += "\t" +item.message; | |
that.textResult += "\r\n"; | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment