summaryrefslogtreecommitdiff
path: root/test/parallel/test-console-stdio-setters.js
blob: 5a4f511ee97bbb21d9e7c66d9e2287c026060163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict';

// Test that monkeypatching console._stdout and console._stderr works.
const common = require('../common');

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

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

// 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;

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