Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
647 views
in Technique[技术] by (71.8m points)

node.js - How to disable Jest `console.log` tags

I have some NodeJS logging done via console.log() internally (its actually loglevel) and as I see it, Jest tags console.log output with console.log ../path/to/string/with/console.log/call:line# for whatever reason:

enter image description here

I haven't found any related options in the docs. How can I disable it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

IMPORTANT:

I had the curiosity to take a look to the answer mentioned in the first answer, wich it says:

Looking at the source code for Jest, it doesn't seem like there is a neat way to turn those messages off.

And I noticed an update marked on the answer and resolves the problem.

Solution:

Just add this code to your test:

beforeEach(() => {
    global.console = require('console');
  });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...