Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const setupConsole = () => {
const testConsole = new BufferedConsole(() => {});
const originalWrite = BufferedConsole.write;
BufferedConsole.write = (...args) => {
// make sure the stack trace still points to the original .log origin.
args[3] = 5;
return originalWrite(...args);
};
const rendererConsole = global.console;
const mergedConsole = {};
Object.getOwnPropertyNames(rendererConsole)
.filter(prop => typeof rendererConsole[prop] === 'function')
.forEach(prop => {
mergedConsole[prop] =
typeof testConsole[prop] === 'function'
? (...args) => {
testConsole[prop](...args);
return rendererConsole[prop](...args);
}
const setupConsole = () => {
const testConsole = new BufferedConsole(() => {});
const originalWrite = BufferedConsole.write;
BufferedConsole.write = (...args) => {
// make sure the stack trace still points to the original .log origin.
args[3] = 5;
return originalWrite(...args);
};
const rendererConsole = global.console;
const mergedConsole = {};
Object.getOwnPropertyNames(rendererConsole)
.filter(prop => typeof rendererConsole[prop] === 'function')
.forEach(prop => {
mergedConsole[prop] =
typeof testConsole[prop] === 'function'
? (...args) => {
testConsole[prop](...args);
return rendererConsole[prop](...args);