Reformatted console output + dotted visualization on runtime
(These changes does not applyed for verbose level) Before: should not pass: failed should not pass: failed should not pass: failed Now: .....x.x.x. Failed level 1:: should not pass: failed Expected true to be false. (1) Failed level 1:: Level 2:: Level 3:: should not pass: failed Expected true to be false. (3) Failed level 1:: Level 2:: Level 3:: Level 4:: should not pass: failed ReferenceError: Can't find variable: asdf in file:///grunt-contrib-jasmine/test/fixtures/pivotal/spec/PlayerSpec.js (line 85) (1)
This commit is contained in:
parent
e96ab59997
commit
d404617cf9
@ -27,7 +27,8 @@ module.exports = function(grunt) {
|
||||
passed : 0,
|
||||
total : 0,
|
||||
skipped : 0,
|
||||
duration : 0
|
||||
duration : 0,
|
||||
log : ''
|
||||
};
|
||||
|
||||
grunt.registerMultiTask('jasmine', 'Run jasmine specs headlessly through PhantomJS.', function() {
|
||||
@ -75,6 +76,12 @@ module.exports = function(grunt) {
|
||||
|
||||
});
|
||||
|
||||
function logWrite(text, isInline) {
|
||||
text += (isInline ? '' : '\n');
|
||||
status.log += text;
|
||||
grunt.verbose.write(text);
|
||||
}
|
||||
|
||||
function phantomRunner(options,cb){
|
||||
var file = options.outfile;
|
||||
|
||||
@ -151,17 +158,30 @@ module.exports = function(grunt) {
|
||||
//grunt.verbose.writeln(suite.description + ": " + suite.results.passedCount + " of " + suite.results.totalCount + " passed.");
|
||||
});
|
||||
|
||||
phantomjs.on('jasmine.reportSpecResults',function(specId, result,summary) {
|
||||
phantomjs.on('jasmine.reportSpecResults',function(specId, result, fullName) {
|
||||
if (result.passed) thisRun.passed_specs++;
|
||||
|
||||
grunt.verbose.writeln(summary.passed ? result.msg.green : result.msg.red);
|
||||
if (!result.passed) {
|
||||
if (grunt.option('verbose'))
|
||||
grunt.verbose.writeln(result.description + ': ' + result.msg.red);
|
||||
else {
|
||||
logWrite(fullName + ': ' + result.msg.red);
|
||||
grunt.log.write('x'.red);
|
||||
}
|
||||
} else {
|
||||
grunt.verbose.writeln(result.description + ': ' + result.msg.green);
|
||||
if (!grunt.option('verbose'))
|
||||
grunt.log.write('.');
|
||||
}
|
||||
|
||||
for (var i = 0; i < result.messages.length; i++) {
|
||||
var item = result.messages[i];
|
||||
|
||||
if (item.type === 'log') {
|
||||
grunt.verbose.writeln(item.toString());
|
||||
} else if (item.type === 'expect' && !item.passed_) {
|
||||
grunt.log.writeln(summary.description + ':' + result.msg.red);
|
||||
var specIndex = ' ('+(i+1)+')';
|
||||
logWrite(' ' + item.message.red+specIndex.red);
|
||||
phantomjs.emit('onError', item.message, item.trace);
|
||||
}
|
||||
}
|
||||
@ -170,9 +190,13 @@ module.exports = function(grunt) {
|
||||
});
|
||||
|
||||
phantomjs.on('jasmine.reportRunnerResults',function(){
|
||||
grunt.verbose.writeln('Runner finished');
|
||||
var dur = (new Date()).getTime() - thisRun.start_time;
|
||||
var spec_str = thisRun.executed_specs + (thisRun.executed_specs === 1 ? " spec " : " specs ");
|
||||
if (!grunt.option('verbose')) {
|
||||
grunt.log.writeln('');
|
||||
grunt.log.write(status.log);
|
||||
}
|
||||
grunt.verbose.writeln('Runner finished');
|
||||
grunt.log.writeln(spec_str + 'in ' + (dur/1000) + "s.");
|
||||
});
|
||||
|
||||
|
@ -150,7 +150,6 @@ phantom.sendMessage = function() {
|
||||
passed : _results.passed(),
|
||||
msg : _results.failedCount > 0 ? "failed" : "passed"
|
||||
};
|
||||
|
||||
this.results_[spec.id] = results;
|
||||
|
||||
// Quick hack to alleviate cyclical object breaking JSONification.
|
||||
@ -163,8 +162,11 @@ phantom.sendMessage = function() {
|
||||
}
|
||||
});
|
||||
|
||||
phantom.sendMessage( 'jasmine.reportSpecResults', spec.id, results, this.resultsForSpec(spec.id));
|
||||
phantom.sendMessage( 'jasmine.reportSpecResults', spec.id, results, this.getFullName(spec));
|
||||
};
|
||||
|
||||
PhantomReporter.prototype.getFullName = function(spec) {
|
||||
return getNestedSuiteName(spec.suite, ':: ') + ':: ' + spec.description;
|
||||
};
|
||||
|
||||
PhantomReporter.prototype.resultsForSpecs = function(specIds){
|
||||
@ -198,13 +200,13 @@ phantom.sendMessage = function() {
|
||||
};
|
||||
};
|
||||
|
||||
function getNestedSuiteName(suite) {
|
||||
function getNestedSuiteName(suite, sep) {
|
||||
var names = [];
|
||||
while (suite) {
|
||||
names.unshift(suite.description);
|
||||
suite = suite.parentSuite;
|
||||
}
|
||||
return names.join(' ');
|
||||
return names.join(sep ? sep : ' ');
|
||||
}
|
||||
|
||||
function getTopLevelSuiteId(suite) {
|
||||
|
Loading…
Reference in New Issue
Block a user