Jest has this feature to log the line that outputs to console
methods.
In some cases, this can become annoying:
console.log _modules/l
Jest injects custom console implementation that is based on extendable Console class into test global scope. Normally it provides useful debugging information alongside printed message that answers the question where potentially unwanted output comes from.
In case this is undesirable for some reason, a simple way to retrieve default console
implementation is to import it from Node built-in module.
Can be done for specific console calls:
let console = require('console');
...
console.log(...)
For many of them that occur inside a range of tests:
const jestConsole = console;
beforeEach(() => {
global.console = require('console');
});
afterEach(() => {
global.console = jestConsole;
});
And so on.