by Robert Axelsen
羅伯特·阿克森(Robert Axelsen)
Google Chrome瀏覽器可能在您不知情的情況下破壞了您的測試 (Google Chrome might have broken your tests without you even knowing about it)
My colleague just discovered that Chrome 58 (released April 19th) has silently muted all console.debug() output in their Chrome Dev Tools.
我的同事剛剛發現Chrome 58(于4月19日發布)已在其Chrome開發工具中靜默靜音了所有console.debug()輸出。
How? By making changes to the Console UI, from filtering based on type of console method to filtering based on levels.
怎么樣? 通過更改控制臺UI ,從基于控制臺方法類型的篩選到基于級別的篩選。
Introducing levels is not a bad thing in and of itself. But Google also chose to stop showing all console output by default. Now you can only see level “Info” and below.
引入級別本身并不是一件壞事。 但是Google默認也選擇停止顯示所有控制臺輸出。 現在,您只能看到“信息”及以下級別。
Depending on your project, it might also be a big deal to no longer be able to filter by showing only one console method’s output.
根據您的項目,可能不再通過僅顯示一個控制臺方法的輸出進行過濾也很重要。
For example only console.log()
. This is particularly troublesome if you’re working on a larger project with hundreds of different types of output mixed together.
例如僅console.log()
。 如果您正在處理一個大型項目,將數百種不同類型的輸出混合在一起,則這尤其麻煩。
As you can see from the comments section in the release notes, this has not been received well by developers.
從發行說明的注釋部分可以看出,開發人員對此并不滿意。
測試失敗 (Failing Tests)
This means that if your app or project relies on console.debug()
level output for testing, your tests might have been failing for over a month without you even noticing.
這意味著如果您的應用程序或項目依賴console.debug()
級別的輸出進行測試,則您的測試可能已經失敗了一個多月,甚至沒有引起您的注意。
All without so much as a pop-up warning from Google.
所有這些都沒有來自Google的彈出警告。
By making logging non-verbose by default, I believe Google has broken with best practice here, and made a huge mistake.
通過默認將日志記錄設置為非冗長,我相信Google違反了此處的最佳做法,并犯了一個嚴重錯誤。
Also, removing the ability to only show output based on a specific console method has resulted in a worsened workflow for many developers.
此外,刪除僅基于特定控制臺方法顯示輸出的功能也導致許多開發人員的工作流程變糟。
自己測試一下 (Test it out for yourself)
I did some testing with the following console methods in Chrome Dev Tools:
我使用Chrome開發工具中的以下控制臺方法進行了一些測試:
console.assert(true, {assert: "assert"});console.count('count');console.debug('debug');console.dir({dir: "dir"});console.error('error');console.info('info');console.log('log');console.profile('profile');setTimeout(function(){ console.profileEnd('profile'); }, 1000);console.table('table');console.time('time');setTimeout(function(){ console.timeEnd('time'); }, 1000);console.timeStamp('timeStamp');console.trace('trace');console.warn('warn');
You can simply copy paste this into the console in Chrome Dev Tools, hit enter, and change the filter level to see what is displayed in which level.
您可以簡單地將其復制粘貼到Chrome Dev Tools中的控制臺中,按Enter,然后更改過濾器級別以查看哪個級別顯示了什么。
一些截圖說明 (Some Screenshots To Illustrate)
Here are some screenshots to illustrate the differences between levels. Notice especially the first screenshot of default “Info” level, and the fact that “3 items are hidden.”
以下是一些屏幕截圖,用于說明各個級別之間的差異。 特別要注意默認“信息”級別的第一張屏幕截圖,以及“隱藏了3個項目”這一事實。
有什么想法嗎? (Have Any Thoughts?)
What do you think about this change? Was Google in the wrong for making this change? Or do you think it was an improvement to the “Console UI” overall? Please leave a comment below.
您如何看待這種變化? Google做出此更改錯了嗎? 還是您認為這是對“控制臺UI”整體的改進? 請在下面發表評論。
This article was originally published on “Hello, I Love Code” and is written by Robert Axelsen, who is a JavaScript Developer, Meetup Organizer and Open Source enthusiast based in Austria, Europe.
本文最初發表在“你好,我愛代碼”上 ,由羅伯特·阿克塞爾森 ( Robert Axelsen )撰寫,他是JavaScript開發人員,Meetup組織者和開放源代碼愛好者,來自歐洲奧地利。
You can connect with Robert on Twitter, or get to know him better by visiting his website.
您可以在Twitter上與Robert聯系,或者通過訪問他的網站來更好地了解他。
翻譯自: https://www.freecodecamp.org/news/google-chrome-might-have-broken-your-tests-without-you-even-knowing-about-it-9d9130a6fd0c/