Jest 吞下 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"?
我关心的主要原因是我正在编写一些异步 beforeAll
和 afterAll
东西,我想使用 console.log 语句来调试事件的顺序。
原文由 Joseph Fraley 发布,翻译遵循 CC BY-SA 4.0 许可协议
这似乎是一个 持续的问题。
使用 Node 10.7.0 和 Jest 23.4.1,将
verbose: false
添加到 jest 配置( 根据此建议)对我有用。编辑
现在我已经转到 Jest 23.6,我还需要根据 Tamlyn 的回答将
TERM=dumb
作为环境变量传递。