Allow AtomReporter to output text to console.

This commit is contained in:
Corey Johnson 2012-03-14 10:48:53 -07:00
parent 131d5775bf
commit 117d9287e0
3 changed files with 6 additions and 25 deletions

View File

@ -11,11 +11,10 @@ $('head').append $$ ->
@link rel: "stylesheet", type: "text/css", href: "static/jasmine.css"
$('body').append $$ ->
@div id: 'jasmine_runner'
@div id: 'jasmine-content'
jasmineEnv = jasmine.getEnv()
atomReporter = new jasmine.AtomReporter(document, 'jasmine_runner')
atomReporter = new jasmine.AtomReporter(document, false)
jasmineEnv.addReporter(atomReporter)

View File

@ -11,11 +11,10 @@ $('head').append $$ ->
@link rel: "stylesheet", type: "text/css", href: "static/jasmine.css"
$('body').append $$ ->
@div id: 'jasmine_runner'
@div id: 'jasmine-content'
jasmineEnv = jasmine.getEnv()
atomReporter = new jasmine.AtomReporter(document, 'jasmine_runner')
atomReporter = new jasmine.AtomReporter(document)
jasmineEnv.addReporter(atomReporter)

View File

@ -1,7 +1,7 @@
jasmine.AtomReporter = function(doc) {
jasmine.AtomReporter = function(doc, logRunningSpecs) {
this.document = doc || document;
this.suiteDivs = {};
this.logRunningSpecs = false;
this.logRunningSpecs = logRunningSpecs == false ? false : true;
};
jasmine.AtomReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
@ -91,8 +91,6 @@ jasmine.AtomReporter.prototype.reportRunnerResults = function(runner) {
var results = runner.results();
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
this.runnerDiv.setAttribute("class", className);
//do it twice for IE
this.runnerDiv.setAttribute("className", className);
var specs = runner.specs();
var specCount = 0;
for (var i = 0; i < specs.length; i++) {
@ -118,12 +116,6 @@ jasmine.AtomReporter.prototype.reportSuiteResults = function(suite) {
this.suiteDivs[suite.id].className += " " + status;
};
jasmine.AtomReporter.prototype.reportSpecStarting = function(spec) {
if (this.logRunningSpecs) {
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
}
};
jasmine.AtomReporter.prototype.reportSpecResults = function(spec) {
var results = spec.results();
var status = results.passed() ? 'passed' : 'failed';
@ -148,9 +140,11 @@ jasmine.AtomReporter.prototype.reportSpecResults = function(spec) {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
} else if (result.type == 'expect' && result.passed && !result.passed()) {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
if (this.logRunningSpecs) console.log(spec.getFullName())
if (result.trace.stack) {
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
if (this.logRunningSpecs) console.log(result.trace.stack)
}
}
}
@ -162,17 +156,6 @@ jasmine.AtomReporter.prototype.reportSpecResults = function(spec) {
this.suiteDivs[spec.suite.id].appendChild(specDiv);
};
jasmine.AtomReporter.prototype.log = function() {
var console = jasmine.getGlobal().console;
if (console && console.log) {
if (console.log.apply) {
console.log.apply(console, arguments);
} else {
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
}
}
};
jasmine.AtomReporter.prototype.getLocation = function() {
return this.document.location;
};