By default don't display "Jasmine Running..." console log for each spec. Re-enable by setting TrivialReporter's logRunningSpecs to true.
This commit is contained in:
parent
2939aff80c
commit
22065fafad
|
@ -1,6 +1,7 @@
|
|||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
|
@ -115,6 +116,12 @@ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
|||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
|
|
|
@ -10,11 +10,26 @@ describe("jasmine.MultiReporter", function() {
|
|||
});
|
||||
|
||||
it("should support all the method calls that jasmine.Reporter supports", function() {
|
||||
multiReporter.reportRunnerStarting();
|
||||
multiReporter.reportRunnerResults();
|
||||
multiReporter.reportSuiteResults();
|
||||
multiReporter.reportSpecResults();
|
||||
multiReporter.log();
|
||||
var delegate = {};
|
||||
multiReporter.addReporter(delegate);
|
||||
|
||||
this.addMatchers({
|
||||
toDelegateMethod: function(methodName) {
|
||||
delegate[methodName] = jasmine.createSpy(methodName);
|
||||
this.actual[methodName]("whatever argument");
|
||||
|
||||
return delegate[methodName].wasCalled
|
||||
&& delegate[methodName].mostRecentCall.args.length == 1
|
||||
&& delegate[methodName].mostRecentCall.args[0] == "whatever argument";
|
||||
}
|
||||
});
|
||||
|
||||
expect(multiReporter).toDelegateMethod('reportRunnerStarting');
|
||||
expect(multiReporter).toDelegateMethod('reportRunnerResults');
|
||||
expect(multiReporter).toDelegateMethod('reportSuiteResults');
|
||||
expect(multiReporter).toDelegateMethod('reportSpecStarting');
|
||||
expect(multiReporter).toDelegateMethod('reportSpecResults');
|
||||
expect(multiReporter).toDelegateMethod('log');
|
||||
});
|
||||
|
||||
it("should delegate to any and all subreporters", function() {
|
||||
|
|
|
@ -205,4 +205,31 @@ describe("TrivialReporter", function() {
|
|||
expect(failedSpecDiv.innerHTML).not.toContain("this one passes!");
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reportSpecStarting', function() {
|
||||
var spec1;
|
||||
beforeEach(function () {
|
||||
env.describe("suite 1", function() {
|
||||
spec1 = env.it("spec 1", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('DOES NOT log running specs by default', function() {
|
||||
spyOn(trivialReporter, 'log');
|
||||
|
||||
trivialReporter.reportSpecStarting(spec1);
|
||||
|
||||
expect(trivialReporter.log).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('logs running specs when log_running_specs is true', function() {
|
||||
trivialReporter.logRunningSpecs = true;
|
||||
spyOn(trivialReporter, 'log');
|
||||
|
||||
trivialReporter.reportSpecStarting(spec1);
|
||||
|
||||
expect(trivialReporter.log).toHaveBeenCalledWith('>> Jasmine Running suite 1 spec 1...');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -82,7 +82,6 @@ describe('WaitsForBlock', function () {
|
|||
var failMessage = spec.fail.mostRecentCall.args[0].message;
|
||||
expect(failMessage).toMatch(message);
|
||||
expect(onComplete).wasNotCalled();
|
||||
|
||||
});
|
||||
});
|
||||
});
|
|
@ -11,7 +11,14 @@ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
|
|||
};
|
||||
|
||||
(function() {
|
||||
var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
|
||||
var functionNames = [
|
||||
"reportRunnerStarting",
|
||||
"reportRunnerResults",
|
||||
"reportSuiteResults",
|
||||
"reportSpecStarting",
|
||||
"reportSpecResults",
|
||||
"log"
|
||||
];
|
||||
for (var i = 0; i < functionNames.length; i++) {
|
||||
var functionName = functionNames[i];
|
||||
jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
|
||||
|
|
|
@ -17,6 +17,10 @@ jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
|
|||
jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
jasmine.Reporter.prototype.reportSpecResults = function(spec) {
|
||||
};
|
||||
|
|
|
@ -134,7 +134,8 @@ jasmine.Spec.prototype.execute = function(onComplete) {
|
|||
spec.finish(onComplete);
|
||||
return;
|
||||
}
|
||||
this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
|
||||
|
||||
this.env.reporter.reportSpecStarting(this);
|
||||
|
||||
spec.env.currentSpec = spec;
|
||||
|
||||
|
|
Loading…
Reference in New Issue