integrating TrivialConsoleReporter into node_suite.js, deleting some code pulled over from jasmine-node
This commit is contained in:
parent
e826fbb170
commit
38e9af8f68
@ -36,102 +36,14 @@ delete global.window;
|
||||
|
||||
function noop(){}
|
||||
|
||||
jasmine.executeSpecs = function(specs, done, isVerbose, showColors){
|
||||
var log = [];
|
||||
var columnCounter = 0;
|
||||
var start = 0;
|
||||
var elapsed = 0;
|
||||
var verbose = isVerbose || false;
|
||||
var colors = showColors || false;
|
||||
|
||||
var ansi = {
|
||||
green: '\033[32m',
|
||||
red: '\033[31m',
|
||||
yellow: '\033[33m',
|
||||
none: '\033[0m'
|
||||
};
|
||||
|
||||
jasmine.executeSpecs = function(specs, done){
|
||||
for (var i = 0, len = specs.length; i < len; ++i){
|
||||
var filename = specs[i];
|
||||
require(filename.replace(/\.\w+$/, ""));
|
||||
}
|
||||
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.reporter = {
|
||||
log: function(str){
|
||||
},
|
||||
|
||||
reportSpecStarting: function(runner) {
|
||||
},
|
||||
|
||||
reportRunnerStarting: function(runner) {
|
||||
sys.puts('Started');
|
||||
start = new Date().getTime();
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var specResults = suite.results();
|
||||
var path = [];
|
||||
while(suite) {
|
||||
path.unshift(suite.description);
|
||||
suite = suite.parentSuite;
|
||||
}
|
||||
var description = path.join(' ');
|
||||
|
||||
if (verbose)
|
||||
log.push('Spec ' + description);
|
||||
|
||||
specResults.items_.forEach(function(spec){
|
||||
if (spec.failedCount > 0 && spec.description) {
|
||||
if (!verbose)
|
||||
log.push(description);
|
||||
log.push(' it ' + spec.description);
|
||||
spec.items_.forEach(function(result){
|
||||
log.push(' ' + result.trace.stack + '\n');
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var result = spec.results();
|
||||
var msg = '';
|
||||
if (result.passed())
|
||||
{
|
||||
msg = (colors) ? (ansi.green + '.' + ansi.none) : '.';
|
||||
// } else if (result.skipped) { TODO: Research why "result.skipped" returns false when "xit" is called on a spec?
|
||||
// msg = (colors) ? (ansi.yellow + '*' + ansi.none) : '*';
|
||||
} else {
|
||||
msg = (colors) ? (ansi.red + 'F' + ansi.none) : 'F';
|
||||
}
|
||||
sys.print(msg);
|
||||
if (columnCounter++ < 50) return;
|
||||
columnCounter = 0;
|
||||
sys.print('\n');
|
||||
},
|
||||
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
elapsed = (new Date().getTime() - start) / 1000;
|
||||
sys.puts('\n');
|
||||
log.forEach(function(log){
|
||||
sys.puts(log);
|
||||
});
|
||||
sys.puts('Finished in ' + elapsed + ' seconds');
|
||||
|
||||
var summary = jasmine.printRunnerResults(runner);
|
||||
if(colors)
|
||||
{
|
||||
if(runner.results().failedCount === 0 )
|
||||
sys.puts(ansi.green + summary + ansi.none);
|
||||
else
|
||||
sys.puts(ansi.red + summary + ansi.none);
|
||||
} else {
|
||||
sys.puts(summary);
|
||||
}
|
||||
(done||noop)(runner, log);
|
||||
}
|
||||
};
|
||||
jasmineEnv.reporter = new jasmine.TrivialConsoleReporter(sys.print, done)
|
||||
jasmineEnv.execute();
|
||||
};
|
||||
|
||||
@ -230,4 +142,4 @@ jasmine.executeSpecs(domIndependentSpecs, function(runner, log){
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
}, isVerbose, showColors);
|
||||
}, isVerbose, showColors);
|
Loading…
Reference in New Issue
Block a user