Console.log statements output nothing at all in Je

2020-02-10 10:41发布

console.log statements output nothing at all in Jest. This was working for me yesterday, and all of sudden, it's not working today. I have made zero changes to my config and haven't installed any updates.

I'm not using the --forceExit option. Still seeing this issue.

5条回答
够拽才男人
2楼-- · 2020-02-10 11:23

In my case the problem was that the logs where made when the module is required, so before the start of an actual test case. Change from a top-level import to using require inside the test case fixed the problem.

查看更多
看我几分像从前
3楼-- · 2020-02-10 11:37

in addition to --verbose option which can cause this as mentioned, be aware that the --watch may also cause this bug.

查看更多
家丑人穷心不美
4楼-- · 2020-02-10 11:38

You can run both options together like this --watch --verbose false if you want to also be watching the files and see the output.

for one time runs just do --verbose false

查看更多
Viruses.
5楼-- · 2020-02-10 11:39

Also be sure that your jest config does not have silent: true. In my case, I didn't realize that someone else had added that to our config.

I don't see it in the list of config options, but the command line flag is documented here.

查看更多
做个烂人
6楼-- · 2020-02-10 11:42

As per comment on https://github.com/facebook/jest/issues/2441,

Try setting verbose: false (or removing it) in the jest options in package.json.

查看更多
登录 后发表回答