[英]How can I tell Jest not to suppress console output on failure?
似乎需要--silent=false
或--verbose=false
的某種組合才能從 Jest 獲取console.log
output 。 但是當我的測試失敗時(即拋出錯誤),這些選項似乎都無濟於事(在 Jest 29.3
中):
test('console output', () => {
console.log('this never prints')
throw new Error('but why?!?') // or 'expect(true).toBe(false)'
})
為什么,哦,為什么,傑斯特,你要這樣做嗎? 失敗的測試正是我最需要控制台(即調試)output 的時候。
我怎么能看到console.log
output 而不管測試中的某些東西是否拋出錯誤?
// Jest configuration file (jest.config.js)
module.exports = {
errorOnDeprecated: true,
verbose: true,
forceExit: false,
};
errorOnDeprecated
選項設置為true
時,將導致 Jest 在使用已棄用的功能時拋出錯誤。 這將防止 Jest 抑制棄用功能的控制台 output,並允許您看到測試運行的完整 output。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.