Jest是否吞下console.log语句?有办法改变吗? [英] Does Jest swallow console.log statements? Is there a way to change this?

查看:1129
本文介绍了Jest是否吞下console.log语句?有办法改变吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

玩笑会吞下console.log输出吗?

// __tests__/log.test.js

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

// terminal output
$ jest --forceExit
PASS  __tests__/log.test.js
✓ logs (1ms) # where's "hey"?

我关心的主要原因是我正在编写一些异步的beforeAllafterAll东西,并且我想使用console.log语句调试事件的顺序.

The main reason I care is that I'm writing some async beforeAll and afterAll stuff, and I want to use console.log statements to debug the order of events.

推荐答案

这似乎是进行中问题.

使用节点10.7.0和Jest 23.4.1,将verbose: false添加到jest配置中(

With Node 10.7.0 and Jest 23.4.1, adding verbose: false to the jest config (per this suggestion) worked for me.

修改

现在我已经进入Jest 23.6,根据Tamlyn的回答,我还需要将TERM=dumb作为环境变量传递.

Now that I've gone to Jest 23.6 I also need to pass TERM=dumb as an environment variable, per Tamlyn's answer.

这篇关于Jest是否吞下console.log语句?有办法改变吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆