Skip to content
Browse files

Functional result logging.

  • Loading branch information...
1 parent 42f7384 commit 6f1d64caf7b473c3f90a8b94d8cb42c6eda56e67 @Yuffster committed
Showing with 17 additions and 8 deletions.
  1. +17 −8 describe.js
View
25 describe.js
@@ -12,28 +12,37 @@
callbackMode: false
};
- function outputDOM(data, options) {
+ function outputDOM(data) {
String.prototype.color = function(color) {
return '<span style="color:'+color+';font-weight:bold;">'+this+"</span>";
};
- document.body.innerHTML = "<pre>"+outputConsole(data, options)+"</pre>";
+ document.body.innerHTML = "<pre>"+getOutput(data)+"</pre>";
}
function outputConsole(data, options) {
- if (!String.prototype.color) require('string-color');
+ require('string-color');
+
+ console.log(getOutput(data));
+
+ process.exit(data.total-data.passed);
+
+ }
+
+ function getOutput(data) {
+
+ var output = "";
for (var k in data.errors) {
- console.log(k.color('red'));
- console.log(data.errors[k].stack || data.errors[k]);
+ output += k.color('red')+"\n";
+ output += (data.errors[k].stack || data.errors[k])+"\n";
}
- var output = "";
if (data.passed!==data.total) output += "FAILED".color('red');
else output += "PASSED".color('green');
output += ": "+data.passed+"/"+data.total;
- console.log(output);
+ return output;
}
@@ -164,7 +173,7 @@
else resultCallbacks[resultCallbacks.length] = cb;
}
- describe.logResults = function(options) {
+ describe.logResults = function() {
describe.getResults(function(data) {
if (typeof window !== "undefined") outputDOM(data, options);
else outputConsole(data, options);

0 comments on commit 6f1d64c

Please sign in to comment.
Something went wrong with that request. Please try again.