* Removed old Queue & Runner in favor of Suite using the new QueueRunner
* New reporter interface across all reporters * xdescribe & xit now store disabled specs * Rewrite of HtmlReporter to support new interface and be more performant
This commit is contained in:
committed by
Dan Hansen and Davis W. Frank
parent
05977203a6
commit
3fc79bac9e
@@ -1,55 +1,72 @@
|
||||
jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
||||
//inspired by mhevery's jasmine-node reporter
|
||||
//https://github.com/mhevery/jasmine-node
|
||||
|
||||
doneCallback = doneCallback || function() {};
|
||||
|
||||
var ansi = {
|
||||
jasmine.ConsoleReporter = function(options) {
|
||||
var print = options.print,
|
||||
showColors = options.showColors || false,
|
||||
onComplete = options.onComplete || function() {},
|
||||
now = options.now || function() { return new Date().getTime();},
|
||||
startTime = 0,
|
||||
specCount,
|
||||
failureCount,
|
||||
failedSpecs = [],
|
||||
ansi = {
|
||||
green: '\033[32m',
|
||||
red: '\033[31m',
|
||||
yellow: '\033[33m',
|
||||
none: '\033[0m'
|
||||
},
|
||||
language = {
|
||||
spec: "spec",
|
||||
failure: "failure"
|
||||
};
|
||||
|
||||
function coloredStr(color, str) {
|
||||
return showColors ? (ansi[color] + str + ansi.none) : str;
|
||||
}
|
||||
this.jasmineStarted = function() {
|
||||
startTime = now();
|
||||
specCount = 0;
|
||||
failureCount = 0;
|
||||
print("Started");
|
||||
printNewline();
|
||||
};
|
||||
|
||||
function greenStr(str) {
|
||||
return coloredStr("green", str);
|
||||
}
|
||||
this.jasmineDone = function() {
|
||||
var elapsed = now() - startTime;
|
||||
|
||||
function redStr(str) {
|
||||
return coloredStr("red", str);
|
||||
}
|
||||
printNewline();
|
||||
for (var i = 0; i < failedSpecs.length; i++) {
|
||||
specFailureDetails(failedSpecs[i]);
|
||||
}
|
||||
|
||||
function yellowStr(str) {
|
||||
return coloredStr("yellow", str);
|
||||
}
|
||||
printNewline();
|
||||
var specCounts = specCount + " " + plural("spec", specCount) + ", " +
|
||||
failureCount + " " + plural("failure", failureCount);
|
||||
print(specCounts);
|
||||
|
||||
function newline() {
|
||||
printNewline();
|
||||
var seconds = elapsed / 1000;
|
||||
print("Finished in " + seconds + " " + plural("second", seconds));
|
||||
|
||||
printNewline();
|
||||
|
||||
onComplete();
|
||||
};
|
||||
|
||||
this.specDone = function(result) {
|
||||
specCount++;
|
||||
|
||||
if (result.status == "passed") {
|
||||
print(colored("green", '.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == "failed") {
|
||||
failureCount++;
|
||||
failedSpecs.push(result);
|
||||
print(colored("red", 'F'));
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function printNewline() {
|
||||
print("\n");
|
||||
}
|
||||
|
||||
function started() {
|
||||
print("Started");
|
||||
newline();
|
||||
}
|
||||
|
||||
function greenDot() {
|
||||
print(greenStr("."));
|
||||
}
|
||||
|
||||
function redF() {
|
||||
print(redStr("F"));
|
||||
}
|
||||
|
||||
function yellowStar() {
|
||||
print(yellowStr("*"));
|
||||
function colored(color, str) {
|
||||
return showColors ? (ansi[color] + str + ansi.none) : str;
|
||||
}
|
||||
|
||||
function plural(str, count) {
|
||||
@@ -73,129 +90,16 @@ jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
||||
return newArr.join("\n");
|
||||
}
|
||||
|
||||
// function specFailureDetails(suiteDescription, specDescription, stackTraces) {
|
||||
// newline();
|
||||
// print(suiteDescription + " " + specDescription);
|
||||
// newline();
|
||||
// for (var i = 0; i < stackTraces.length; i++) {
|
||||
// print(indent(stackTraces[i], 2));
|
||||
// newline();
|
||||
// }
|
||||
// }
|
||||
function specFailureDetails(specFailure) {
|
||||
newline();
|
||||
print(specFailure.fullName);
|
||||
newline();
|
||||
for (var i = 0; i < specFailure.failedExpectations.length; i++) {
|
||||
var failedExpectation = specFailure.failedExpectations[i];
|
||||
function specFailureDetails(result) {
|
||||
printNewline();
|
||||
print(result.fullName);
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var failedExpectation = result.failedExpectations[i];
|
||||
printNewline();
|
||||
print(indent(failedExpectation.trace.stack, 2));
|
||||
newline();
|
||||
}
|
||||
}
|
||||
|
||||
function finished(elapsed) {
|
||||
newline();
|
||||
print("Finished in " + elapsed / 1000 + " seconds");
|
||||
}
|
||||
|
||||
function summary(colorF, specs, failed) {
|
||||
newline();
|
||||
print(colorF(specs + " " + plural(language.spec, specs) + ", " +
|
||||
failed + " " + plural(language.failure, failed)));
|
||||
newline();
|
||||
newline();
|
||||
}
|
||||
|
||||
function greenSummary(specs, failed) {
|
||||
summary(greenStr, specs, failed);
|
||||
}
|
||||
|
||||
function redSummary(specs, failed) {
|
||||
summary(redStr, specs, failed);
|
||||
}
|
||||
|
||||
function fullSuiteDescription(suite) {
|
||||
var fullDescription = suite.description;
|
||||
if (suite.parentSuite) fullDescription = fullSuiteDescription(suite.parentSuite) + " " + fullDescription;
|
||||
return fullDescription;
|
||||
}
|
||||
|
||||
this.now = function() {
|
||||
return new Date().getTime();
|
||||
};
|
||||
|
||||
this.reportRunnerStarting = function() {
|
||||
this.runnerStartTime = this.now();
|
||||
started();
|
||||
};
|
||||
|
||||
this.reportSpecStarting = function() { /* do nothing */
|
||||
};
|
||||
|
||||
this.specFailures = [];
|
||||
this.specCount = 0;
|
||||
this.reportSpecResults = function(result) {
|
||||
this.specCount++;
|
||||
if (result.status === 'disabled') {
|
||||
yellowStar();
|
||||
} else if (result.status === 'passed') {
|
||||
greenDot();
|
||||
} else {
|
||||
redF();
|
||||
this.specFailures.push(result);
|
||||
}
|
||||
};
|
||||
|
||||
// this.suiteResults = [];
|
||||
|
||||
this.reportSuiteResults = function(suite) {
|
||||
// var suiteResult = {
|
||||
// description: fullSuiteDescription(suite),
|
||||
// failedSpecResults: []
|
||||
// };
|
||||
|
||||
// suite.results().items_.forEach(function(spec) {
|
||||
// if (spec.failedCount > 0 && spec.description) suiteResult.failedSpecResults.push(spec);
|
||||
// });
|
||||
|
||||
// this.suiteResults.push(suiteResult);
|
||||
};
|
||||
|
||||
// function eachSpecFailure(suiteResults, callback) {
|
||||
// for (var i = 0; i < suiteResults.length; i++) {
|
||||
// var suiteResult = suiteResults[i];
|
||||
// for (var j = 0; j < suiteResult.failedSpecResults.length; j++) {
|
||||
// var failedSpecResult = suiteResult.failedSpecResults[j];
|
||||
// var stackTraces = [];
|
||||
// for (var k = 0; k < failedSpecResult.items_.length; k++) stackTraces.push(failedSpecResult.items_[k].trace.stack);
|
||||
// callback(suiteResult.description, failedSpecResult.description, stackTraces);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
function eachSpecFailure(specResult, callback) {
|
||||
for (var i = 0; i < suiteResults.length; i++) {
|
||||
var suiteResult = suiteResults[i];
|
||||
for (var j = 0; j < suiteResult.failedSpecResults.length; j++) {
|
||||
var failedSpecResult = suiteResult.failedSpecResults[j];
|
||||
var stackTraces = [];
|
||||
for (var k = 0; k < failedSpecResult.items_.length; k++) stackTraces.push(failedSpecResult.items_[k].trace.stack);
|
||||
callback(suiteResult.description, failedSpecResult.description, stackTraces);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.reportRunnerResults = function(runner) {
|
||||
newline();
|
||||
|
||||
for (var i = 0; i < this.specFailures.length; i++) {
|
||||
specFailureDetails(this.specFailures[i]);
|
||||
}
|
||||
|
||||
finished(this.now() - this.runnerStartTime);
|
||||
|
||||
var summaryFunction = this.specFailures.length === 0 ? greenSummary : redSummary;
|
||||
summaryFunction(this.specCount, this.specFailures.length);
|
||||
doneCallback(!!this.specFailures.length);
|
||||
};
|
||||
printNewline();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user