Skip to content

Commit

Permalink
test: fix test-console-stdio-setters to test setters
Browse files Browse the repository at this point in the history
test-console-stdio-setters needs to test against the global console in
order to test the setters for the lazy-loaded _stdout and _stderr
properties.

PR-URL: #26796
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Trott authored and targos committed Mar 27, 2019
1 parent 6911678 commit 6874288
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions test/parallel/test-console-stdio-setters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
const common = require('../common');

const { Writable } = require('stream');
const { Console } = require('console');

const streamToNowhere = new Writable({ write: common.mustCall() });
const anotherStreamToNowhere = new Writable({ write: common.mustCall() });
const myConsole = new Console(process.stdout);

// Overriding the _stdout and _stderr properties this way is what we are
// testing. Don't change this to be done via arguments passed to the constructor
// above.
myConsole._stdout = streamToNowhere;
myConsole._stderr = anotherStreamToNowhere;
// Overriding the lazy-loaded _stdout and _stderr properties this way is what we
// are testing. Don't change this to be a Console instance from calling a
// constructor. It has to be the global `console` object.
console._stdout = streamToNowhere;
console._stderr = anotherStreamToNowhere;

myConsole.log('fhqwhgads');
myConsole.error('fhqwhgads');
console.log('fhqwhgads');
console.error('fhqwhgads');

0 comments on commit 6874288

Please sign in to comment.