Skip to content

Commit

Permalink
Merge pull request #1473 from glenjamin/stdout-only
Browse files Browse the repository at this point in the history
only write to stdout in reporters
  • Loading branch information
Travis Jeffery committed Dec 15, 2014
2 parents 8b17dbf + 58f2aca commit a9b48c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
9 changes: 4 additions & 5 deletions lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ exports.cursor = {
*/

exports.list = function(failures){
console.error();
console.log();
failures.forEach(function(test, i){
// format
var fmt = color('error title', ' %s) %s:\n')
Expand Down Expand Up @@ -200,7 +200,7 @@ exports.list = function(failures){
stack = stack.slice(index ? index + 1 : index)
.replace(/^/gm, ' ');

console.error(fmt, (i + 1), test.fullTitle(), msg, stack);
console.log(fmt, (i + 1), test.fullTitle(), msg, stack);
});
};

Expand Down Expand Up @@ -305,11 +305,10 @@ Base.prototype.epilogue = function(){
if (stats.failures) {
fmt = color('fail', ' %d failing');

console.error(fmt,
stats.failures);
console.log(fmt, stats.failures);

Base.list(this.failures);
console.error();
console.log();
}

console.log();
Expand Down
24 changes: 12 additions & 12 deletions test/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ describe('Base reporter', function () {

it('should show diffs with showDiff property set', function () {
var err = new Error('test'),
stderr = [],
stderrWrite = process.stderr.write,
stdout = [],
stdoutWrite = process.stdout.write,
errOut;

err.actual = "a1";
Expand All @@ -18,15 +18,15 @@ describe('Base reporter', function () {
}
};

process.stderr.write = function (string) {
stderr.push(string);
process.stdout.write = function (string) {
stdout.push(string);
};

Base.list([test]);

process.stderr.write = stderrWrite;
process.stdout.write = stdoutWrite;

errOut = stderr.join('\n');
errOut = stdout.join('\n');

errOut.should.match(/test/);
errOut.should.match(/actual/);
Expand All @@ -36,8 +36,8 @@ describe('Base reporter', function () {

it('should not show diffs when showDiff property set', function () {
var err = new Error('test'),
stderr = [],
stderrWrite = process.stderr.write,
stdout = [],
stdoutWrite = process.stdout.write,
errOut;

err.actual = "a1";
Expand All @@ -50,15 +50,15 @@ describe('Base reporter', function () {
}
};

process.stderr.write = function (string) {
stderr.push(string);
process.stdout.write = function (string) {
stdout.push(string);
};

Base.list([test]);

process.stderr.write = stderrWrite;
process.stdout.write = stdoutWrite;

errOut = stderr.join('\n');
errOut = stdout.join('\n');

errOut.should.match(/test/);
errOut.should.not.match(/actual/);
Expand Down

0 comments on commit a9b48c8

Please sign in to comment.