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语句来调试事件的顺序。
问题是我正在使用 jest --forceExit
。 Jest的日志记录模型会保存所有日志并在以后将其吐出。 --forceExit
导致进程在到达spit-out-logs点之前保释。
问题是我正在使用 jest --forceExit
。 Jest的日志记录模型会保存所有日志并在以后将其吐出。 --forceExit
导致进程在到达spit-out-logs点之前保释。
这似乎是一个 持续的问题。
使用Node 10.7.0和Jest 23.4.1,添加 verbose: false
到jest配置(根据这个建议)为我工作。
另一个部分解决方案 目前的错误 影响测试 --watch
模式是通过 TERM=dumb
作为环境变量。
TERM=dumb jest --watch
这个价格很小,因为它不再在每次测试运行之前清除控制台,你必须滚动才能看到结果。