Console.log statements output nothing at all in Jest

三世轮回 提交于 2019-11-27 22:54:39

问题


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.


回答1:


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.




回答2:


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




回答3:


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




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/48695717/console-log-statements-output-nothing-at-all-in-jest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!