Console.log statements output nothing at all in Jest

前端 未结 8 1914
挽巷
挽巷 2020-12-05 22:11

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

相关标签:
8条回答
  • 2020-12-05 22:52

    In my case, the issue was caused by [only] flag

    0 讨论(0)
  • 2020-12-05 22:57

    Check for your command line flags in package.json to see that you don't have --silent in there.

    0 讨论(0)
  • 2020-12-05 22:58

    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.

    0 讨论(0)
  • 2020-12-05 23:02

    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.

    0 讨论(0)
  • 2020-12-05 23:07

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

    0 讨论(0)
  • 2020-12-05 23:07

    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.

    0 讨论(0)
提交回复
热议问题