Skip to content

Commit

Permalink
More workey, but not much
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Moultrie committed Mar 4, 2014
1 parent ce0bc06 commit 7ee2e26
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 177 deletions.
18 changes: 9 additions & 9 deletions lib/jasmine-node/boot.js
Expand Up @@ -156,15 +156,15 @@
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;

window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
// var currentWindowOnload = window.onload;
//
// window.onload = function() {
// if (currentWindowOnload) {
// currentWindowOnload();
// }
// htmlReporter.initialize();
// //env.execute();
// };

/**
* Helper function for readability above.
Expand Down
3 changes: 0 additions & 3 deletions lib/jasmine-node/console.js
Expand Up @@ -34,15 +34,12 @@ getJasmineRequireObj().console = function(jRequire, j$) {
};

getJasmineRequireObj().ConsoleReporter = function() {
console.log('asdfasdfasd');

var noopTimer = {
start: function(){},
elapsed: function(){ return 0; }
};

function ConsoleReporter(options) {
console.log('ahdsf', options);
var print = options.print,
showColors = options.showColors || false,
onComplete = options.onComplete || function() {},
Expand Down
19 changes: 7 additions & 12 deletions lib/jasmine-node/index.js
Expand Up @@ -137,18 +137,11 @@ jasmine.executeSpecsInFolder = function(options){
onComplete: done,
stackFilter: removeJasmineFrames}));
} else {
console.log('console reporter!');
console.log(util.inspect(jasmine))
reporter = new jasmine.ConsoleReporter({print: print, color: true});
console.log(reporter());
jasmineEnv.addReporter(reporter);

//jasmineEnv.addReporter(jasmine.ConsoleReporter({print: print,
//jasmineEnv.addReporter(new jasmine.TerminalReporter({print: print,
// color: showColors
// includeStackTrace: includeStackTrace,
// onComplete: done,
// stackFilter: removeJasmineFrames}));
jasmineEnv.addReporter(new jasmine.TerminalReporter({print: print,
color: showColors,
includeStackTrace: includeStackTrace,
onComplete: done,
stackFilter: removeJasmineFrames}));
}

if (growl) {
Expand All @@ -164,6 +157,8 @@ jasmine.executeSpecsInFolder = function(options){
);
} else {
describe = jasmineEnv.describe;
beforeEach = jasmineEnv.beforeEach;
expect = jasmineEnv.expect;
var specsList = specs.getSpecs();

for (var i = 0, len = specsList.length; i < len; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion lib/jasmine-node/jasmine-2.0.0.js
Expand Up @@ -810,7 +810,7 @@ getJasmineRequireObj().Any = function() {
if (this.expectedObject == Object) {
return typeof other == 'object';
}

if (this.expectedObject == Boolean) {
return typeof other == 'boolean';
}
Expand Down
132 changes: 72 additions & 60 deletions lib/jasmine-node/reporter.js
Expand Up @@ -20,6 +20,8 @@
this.print_ = config.print || function (str) { process.stdout.write(util.format(str)); };
this.color_ = config.color ? this.ANSIColors : this.NoColors;

this.currentSuite_ = null;

this.started_ = false;
this.finished_ = false;

Expand All @@ -32,16 +34,25 @@
this.stackFilter_ = config.stackFilter || function(t) { return t; };
}


jasmineNode.TerminalReporter.prototype = {
reportRunnerStarting: function(runner) {
jasmineStarted: function(runner) {
this.printLine_("Jasmine Starting with " + runner.totalSpecsDefined + " specs");
},
suiteDone: function(done) {
this.reportFailures_();
//console.log(done);
},
// specDone: function(result) {
// console.log(result.status);
// },
suiteStarted: function(suite) {
this.started_ = true;
this.startedAt = new Date();
var suites = runner.topLevelSuites();
for (var i = 0; i < suites.length; i++) {
var suite = suites[i];
this.suites_.push(this.summarize_(suite));
}
this.suites_.push(this.summarize_(suite, true));
this.currentSuite_ = this.suites_[this.suites_.length - 1];
},
specStarted: function(spec) {
this.currentSuite_.children.push(this.summarize_(spec, false));
},

ANSIColors: {
Expand All @@ -62,9 +73,8 @@
neutral: function() { return ''; }
},

summarize_: function(suiteOrSpec) {
var isSuite = suiteOrSpec instanceof jasmine.Suite;

// Builds the description object for the spec or suite
summarize_: function(suiteOrSpec, isSuite) {
// We could use a separate object for suite and spec
var summary = {
id: suiteOrSpec.id,
Expand All @@ -75,21 +85,22 @@
};

if (isSuite) {
var calculateNestingLevel = function(examinedSuite) {
var nestingLevel = 0;
while (examinedSuite.parentSuite !== null) {
nestingLevel += 1;
examinedSuite = examinedSuite.parentSuite;
}
return nestingLevel;
};

summary.suiteNestingLevel = calculateNestingLevel(suiteOrSpec);

var children = suiteOrSpec.children();
for (var i = 0; i < children.length; i++) {
summary.children.push(this.summarize_(children[i]));
}
// var calculateNestingLevel = function(examinedSuite) {
// var nestingLevel = 0;
// while (examinedSuite.parentSuite !== null) {
// nestingLevel += 1;
// examinedSuite = examinedSuite.parentSuite;
// }
// return nestingLevel;
// };

//summary.suiteNestingLevel = calculateNestingLevel(suiteOrSpec);
summary.suiteNestingLevel = 0;

// var children = suiteOrSpec.children();
// for (var i = 0; i < children.length; i++) {
// summary.children.push(this.summarize_(children[i]));
// }
}

return summary;
Expand Down Expand Up @@ -144,39 +155,37 @@
// Not used in this context
},

reportSpecResults: function(spec) {
var result = spec.results();
specDone: function(spec) {
//console.log(spec);
var msg = '';
if (result.skipped) {
if (spec.status === 'skipped') {
msg = this.stringWithColor_('-', this.color_.ignore());
} else if (result.passed()) {
} else if (spec.status === 'passed') {
msg = this.stringWithColor_('.', this.color_.pass());
} else {
} else if (spec.status === 'failed'){
msg = this.stringWithColor_('F', this.color_.fail());
this.addFailureToFailures_(spec);
} else {
msg = this.stringWithColor_('U' + spec.status, this.color_.fail());
}
this.spec_results += msg;
this.print_(msg);
},

addFailureToFailures_: function(spec) {
var result = spec.results();
var failureItem = null;

var items_length = result.items_.length;
for (var i = 0; i < items_length; i++) {
if (result.items_[i].passed_ === false) {
failureItem = result.items_[i];

var failure = {
spec: spec.suite.getFullName() + " " + spec.description,
message: failureItem.message,
stackTrace: failureItem.trace.stack
}

this.failures_.push(failure);
failures = spec.failedExpectations;
for (var i = 0; i < failures.length; i++) {
failure = failures[i];

var failureDesc = {
spec: spec.description,
message: failure.message,
stackTrace: failure.stack
}

this.failures_.push(failureDesc);
}

},

printRunnerResults_: function(runner){
Expand Down Expand Up @@ -223,43 +232,46 @@

jasmineNode.TerminalVerboseReporter.prototype = {

reportSpecStarting: function(spec) {
specStarted: function(spec) {
now = new Date().getTime();
this.specTimes_[spec.id] = now;
var suite = spec.suite;
while (suite) {
if (!this.suiteTimes_[suite.id]) {
this.suiteTimes_[suite.id] = now;
}
suite = suite.parentSuite;
}
// var suite = spec.suite;
// while (suite) {
// if (!this.suiteTimes_[suite.id]) {
// this.suiteTimes_[suite.id] = now;
// }
// suite = suite.parentSuite;
// }
jasmineNode.TerminalReporter.prototype.specStarted.call(this, spec);
},

reportSpecResults: function(spec) {
specDone: function(spec) {
var elapsed = new Date().getTime() - this.specTimes_[spec.id];

if (spec.results().failedCount > 0) {
if (spec.failedExpectations.length > 0) {
this.addFailureToFailures_(spec);
}

this.specResults_[spec.id] = {
messages: spec.results().getItems(),
result: spec.results().failedCount > 0 ? 'failed' : 'passed',
messages: spec.failedExpectations,
result: spec.failedExpectations.length > 0 ? 'failed' : 'passed',
runtime: elapsed
};
jasmineNode.TerminalReporter.prototype.specDone.call(this, spec);
},

reportSuiteResults: function(suite) {
suiteDone: function(suite) {
var startTime = this.suiteTimes_[suite.id];
if (startTime) {
var elapsed = new Date().getTime() - startTime;
this.suiteResults_[suite.id] = {
runtime: elapsed
};
}
jasmineNode.TerminalReporter.prototype.suiteDone.call(this, suite);
},

reportRunnerResults: function(runner) {
jasmineDone: function(runner) {
var messages = new Array();
this.buildMessagesFromResults_(messages, this.suites_);

Expand All @@ -271,7 +283,7 @@
this.print_(messages[messages_length-1]);

// Call the parent object's method
jasmineNode.TerminalReporter.prototype.reportRunnerResults.call(this, runner);
jasmineNode.TerminalReporter.prototype.jasmineDone.call(this, runner);
},

buildMessagesFromResults_: function(messages, results, depth) {
Expand Down

0 comments on commit 7ee2e26

Please sign in to comment.