How do I hide the stack trace from my tests

Viewed 22

every test I run produces 10 pages of pointless node-module stack traces. How do I get rid of them? I don't see this in the youtube testing videos, but I haven't found an answer after weeks.

1 Answers

One way would be to just mock the console.log (or any console's method) out. Don't forget to keep the reference to the original method if you plan to restore it back for some other tests.

/** irreversible version */
console.log = jest.fn();

/** reversible version */
const logRef = console.log;

console.log = jest.fn();

// restore when needed
console.log = logRef;
Related