Does Jest swallow console.log statements? Is there a way to change this?

后端 未结 5 1794
闹比i
闹比i 2021-02-11 17:14

Does Jest swallow console.log output?

// __tests__/log.test.js

it(\'logs\', () => {
  console.log(\'hey\') // expect to see \"hey\" printed in t         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-11 17:57

    Update: this issue should be fixed as of Jest 24.

    Another partial solution to the current bug affecting tests in --watch mode is to pass TERM=dumb as an environment variable.

    TERM=dumb jest --watch
    

    This has a small price in that it no longer clears the console before each test run so you have to scroll to see the results.

提交回复
热议问题